I had to do exactly that in a large Angular project, dince there was no way to provide environment variables available at runtime.
Angular provides an environment mechanism at buildtime, so they expect us to create a docker image per environment, which is not our practice with other microservices in our pipeline. We’re used to kubernetes configMaps.
We used a docker docker runtime script + envsubst as above. However we used it to provide key/values to the window object (inside a template script tag), to be picked up by a proper Angular “AppConfig” service.
I’m not very happy with this solution as it might scare the next maintainers, specially if they don’t know about our ci/cd and backend. The source code is also peppered with little comments about this workaround, which is not ideal.
Angular provides an environment mechanism at buildtime, so they expect us to create a docker image per environment, which is not our practice with other microservices in our pipeline. We’re used to kubernetes configMaps.
We used a docker docker runtime script + envsubst as above. However we used it to provide key/values to the window object (inside a template script tag), to be picked up by a proper Angular “AppConfig” service.
I’m not very happy with this solution as it might scare the next maintainers, specially if they don’t know about our ci/cd and backend. The source code is also peppered with little comments about this workaround, which is not ideal.