I want to remove my local server prefix from my REST API URLs (example, http://localhost:8080) when building for production (ng build --prod
).
I get that i
One way to this approach using containers is by parsing your environment files before you launch your webserver. This assumes that your are following a good practice, that is, you aren't serving your angular application via ng
.
For example, a rudimentary approach would be to craft your index.html
with your desired configuration, this is just an example, do it how you see best:
Before launching your webserver with your static content, use a script that verifies and matches valid environment variables from your configuration window.config
with your actual environment variables.
This is doable with sed
for instance, or if you want to go pro, you may also use [jq][1]
.
After your validation is done, your index.html
has the window.config
object configured following the dev-prod parity approach from 12factors.
Running your docker container would be just,
docker run -it -e ENV_VAR1="my development value" ...
and for production,
docker run -it -e ENV_VAR1="my production value" ...