-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
[Feature Request] Docker: Support Configuration via Environment Variables #45
Comments
Sounds good. What we'd need here is a function to go through the env variables and populate |
That's kind of what I was able to do here. It's still a WIP but it does work. The next bit I was looking at would be adding something like |
I totally forgot that the config file is also used by node. That makes it a bit tricky, for sure. |
Yeah, I started working on it. However, it doesn't seem to be too hard to do. I'll need to test it out in docker to ensure it works before I go through a PR together. Also, what do you think a good flag name for this would be? I threw it together as flag.BoolVar(&f.injectConfig, "inject-config", false, "Inject environment variables to yaml")`, though I am not sure how you would prefer it to be. // RecreateYaml creates a new yaml file with default values and returns a Config.
func RecreateYaml(c Config) (string, error) {
yamlData, err := yaml.Marshal(c)
if err != nil {
return "", err
}
// Return the yaml file content as a string
return string(yamlData), nil
} |
Summary
Currently,
discuit
relies on a YAML file for configuration. While this works well in many scenarios, Docker and other containerized environments often prefer using environment variables for configuration due to their simplicity, security, and ease of use with container orchestration tools like Kubernetes and Docker Compose. This feature request proposes an enhancement to allowdiscuit
to be configured using environment variables, in addition to the existing YAML file-based approach.Motivation
In containerized deployments, managing configuration files can be cumbersome and less secure. Environment variables, on the other hand, can be easily injected into containers at runtime, making them ideal for such environments. Supporting environment variables would make
discuit
more flexible and easier to deploy in a variety of environments, following the twelve-factor app methodology.Proposed Solution
Introduce the capability to read configuration settings from environment variables, with a clear precedence order where environment variables override the settings defined in the YAML file. This allows users to provide a base configuration through the YAML file while overriding specific settings with environment variables as needed.
Considerations
DISCUIT_
to avoid clashes with other environment variables (e.g.,DISCUIT_DBADDR
fordbAddr
).Benefits
discuit
, whether through a file, environment variables, or a combination of both.discuit
with common practices in containerized application deployment.Issues
The text was updated successfully, but these errors were encountered: