-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Load configuration from external file #6711
Comments
Heya, I have to close and link to #3855 here, in order to keep discussion on this topic on the same FAQ labelled issue. I appreciate the alternative solution here, it's similar to mine in #3855 (comment) but a bit more specific to your setup. |
Thanks works wonderfully yet i added some extra code cause i dont wanna to add all the properties: `let finalEnviron:any = function loadJSON(filePath) { function loadTextFileAjaxSync(filePath, mimeType) { function loadVars(finalEnviron){ for (let key in environ) { export const environment = loadVars(finalEnviron);` |
these solutions not works with aot mode. |
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. |
I will try to explain myself the best I could.
The thing is, I want to load the configuration variables that are in the different environments files, from an external file, and not in compilation time.
For what?
If we have that possibility, we can do configuration changes without change any code, deploy, or build anything.
I've made a solution for my actual company, and I'd like to share it here, and see posible alternatives. We are using docker, dcos and consul.
Here is the solution:
/assets/config.tpl.json
This template, is use to replace the values and generate the file which the website reads before load.
/assets/config.json
This file is only used for development in localhost
.angular-cli.json
environments/environment.ts
package.json
Dockerfile
/script/entrypoint.sh
This read from consul the environments variables
/script/replace_and_run.sh
This replace the variables in the template and generates the final file with the config.
The thing is, now, we can modify an endpoint for example, without do anything, just go to consul, change the variable, and it automatically restart de service and with a reload in the website, we see the changes.
I'm here to clarify the doubts, because it's a complex issue...
Thanks to everybody interested!
BR
The text was updated successfully, but these errors were encountered: