-
Notifications
You must be signed in to change notification settings - Fork 12k
configuration via environment variables #2625
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
Comments
The way we support in the CLI is the environment files as documented in https://github.com/angular/angular-cli#build-targets-and-environment-files. There isn't any other way for now. |
Sorry to hijack the thread, but let me ask a related question: what if you want to have secrets that shouldn't be stored along with your code? It's pretty common to have configuration in environmental variables in your server (for example in Azure you set them up through an admin panel). |
That's a very relevant question, and it's the same reason I asked the original question. We deploy our apps using Docker, so all configuration is done using env variables. Besides, it's just not a good idea to store config in source control. Maybe it would be a good idea to have a template for the environment file, and have all the actual files in gitignore. |
My recommendation in that case is to either:
|
Another common requirement is the "build once, deploy many" workflow (i.e. not rebuild each time for a new environment. My experience is that most enterprise devops pipelines work like that.) Are there any plans to support this? The obvious relation to this issue thread is that it's a common mechanism to select your config file by means of an environment variable. In fact, I opened a SO question about this just yesterday. |
There's more information on this in #3855. Of special relevance is #3855 (comment), which explains why the CLI isn't opinionated on runtime configs, and there's a simple example in a followup comment. So that sort of thing is already supported, it just has nothing to do with the build system. |
Would like to add that if anyone is trying to build secrets into their webapp they're exposing those secrets to anyone who visits their website anyway. It would be better to have your secrets managed by a proxy. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Hi
Is there a recommended way to provide configuration via environment variables, instead of hardcoding it in a specific environment..ts file, or rolling my own script to do it?
I'm not well versed in webpack, so perhaps there is a simple way to do it, which is not specific to angular-cli. On the other hand, the webpack configuration is mostly inaccessible, so perhaps that is not viable.
There are quite a few ways to do this of course, so I'm asking if there is a recommended / supported way of doing it, instead of everybody just rolling their own solutions.
Thanks
The text was updated successfully, but these errors were encountered: