[Feature Request] Allow Configuration of Panel via Environment Variables
Closed this issue · 5 comments
Currently configuration of the panel is only possible via the config.json. It would be helpful for non-installer deployments if these settings could be configured via environment variables as well. Specifically it would allow for the config to be specified in docker-compose files and Kubernetes manifests and would make management of secrets like the db and oauth creds easier for people who use secrets management tools like vault.
Alternatively, a solution for kubernetes would be to allow the config.json to be read-only and prevent settings changes from the webui when that is the case. Then config.json can be mounted from a secret.
Currently a workaround for kubernetes is to use an initcontainer to mount the secret somewhere else and copy it to the storage volume as rw. This has the downside that changes in the webui are not persisted between containers.
Hey hey, thanks for you feature request. The storage folder is essential for some moonlight features (e.g. log files and custom images). I can make it that you can pass the configuration file content, so the whole json, as an environment variable. Would you be okay with this way of implementing it or do you have a better idea which i can integrate?
Love the panel, great work!
Passing the whole json as an environment variable would be a big step up for me from the current methods.
Alternatively, I think its preferable, though more work, to expose each config setting manually as environment variables. This is how most container-first applications I've deployed take their configuration. So for moonlight panel you could have the settings exposed with env variables like -
MOONLIGHT_DATABASE__DATABASE
MOONLIGHT_DATABASE__HOST
MOONLIGHT_DATABASE__PASSWORD
MOONLIGHT_LETSENCRYPT__ENABLE
This has the advantage of being able to individually set settings directly in my manifests (e.g. this docker-compose.yml for pterodactyl) which are then kept in source control. My deployment method (fluxcd) makes it very easy to pull individual secrets from vault and set them as env variables in containers. It's possible to do substitution within a template e.g. the config.json but significantly more effort, and requires maintaining the json template somewhere in source. Some of the other benefits of config as env are detailed here.
Hey hey,
the Moonlight__Something
way of implementing config options looks like the best solution and will be implemented in Moonlight v2 (the current version i am working on. For more information, join in discord. Link in docs).
Awesome, thank you!
Elo, using environment variables for loading config options has been implemented in the v2 version of moonlight (more information about v2, see our discord server). v2 builds are not available in this development state
You can set values using the json structure of the config.json.
e.g. the config looks like that:
{ "AppUrl": "http://localhost:5132", ... "Store": { "Currency": "$" }, ... }
You can set the currency using the env var: Moonlight_Store_Currency
If the type of the value is e.g. a integer or a boolean moonlight tries automatically to parse it and ignores the variable if unable to do so.
I hope you are happy with this implementation. If you have any feedback about it, feel free to give feedback ^^