-
Notifications
You must be signed in to change notification settings - Fork 515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker - Build config.json from Environment Variables at runtime #6172
Comments
As I'm working through this, a couple more notes of issues and how I'm attempting to solve them. Any feedback on these approaches would be useful. I should have the pull request ready in the next week or so. Empty StringsOne of the main keys in MeshCentral is the empty string domain key: For the empty string, we can use the null character Case SensitivityI'm not sure if MeshCentral requires case sensitive keys in the config file, but fortunately, environment variables do not require upper case (it is merely by convention that environment variables are all upper-case). As such, values can be rendered exactly as they are in the name. For example, This also means that it's not trivial to check for case errors in the environment variables. My approach here is to simply assume the user is casing everything correctly, and blindly incorporate that into the _Keys (removed config keys)By convention, Javascript uses We can use a special value of We can also recognize empty environment variables, and set the value to the empty string. For example, Other ThoughtsThis concept was mentioned in #22, so I would hope there's some interest in this setup. In that thread, two tools were suggested that can perform this action using Javascript/Typescript. That may be a better approach to this problem, but I'm woefully unskilled in either of those two languages, so I'm sticking with Shell for this. After looking through the Dockerfile, I realized that |
Is your feature request related to a problem? Please describe.
When using the Docker container, many config settings are unconfigurable during setup, and cannot be easily managed afterwards in environments that need high data portability (i.e. volumes).
Describe the solution you'd like
Looking at the Gitea project, they use a standard format to allow all configuration options to be changed via environment variables. This means that any configuration changes can simply be done from a docker-compose file, rather than directly editing their configuration file. For example, you set environment variable
GITEA__database__DB_TYPE=mysql
, and this sets the corresponding config option:Something like this could be done for MeshCentral. Obviously, MeshCentral uses json (whereas Gitea uses ini), so the exact tooling they are using can't be directly ported over, but conceptually the same ideas can be applied.
Additional context
I'm currently working on a shell script-based parser using
jq
that would provide this capability. If there's interest, I'm happy to put together a pull request once I have it complete. The idea is this would replace the currentstartup.sh
file.In order to maintain compatibility with the existing container (and therefore, existing docker-compose files and settings), I'm imagining that it will work as follows:
config.json
file does not exist, create one from the template.MC__a__b__c...
which would map to{"a":{"b":{"c": "value"}}}
, for arbitrary depth.Of note, yaml supports multi-line strings, so it would be easy to make lists or other structures for the few config options that require it. For example, the
webrtcConfig
parameter containsiceServers
, which is a list. You can set that in a docker-compose yaml file as:The text was updated successfully, but these errors were encountered: