Angular 6 + Nginx + Docker + Kubernetes: How to configure environment variables for different environments Angular 6 + Nginx + Docker + Kubernetes: How to configure environment variables for different environments kubernetes kubernetes

Angular 6 + Nginx + Docker + Kubernetes: How to configure environment variables for different environments


One of the ways to solve it would be to add an entrypoint script to your docker image and a default prod env. The use only one environment.ts with something like :

export const environment = {  production: {{production}},  API_URL: '{{api_url}}'};

Dockerfile with

ENV PRODUCTION=true API_URL=https://prod-server.domain.comADD entrypoint.sh /entrypoint.shENTRYPOINT /entrypoint.sh

and finally entrypoint it self

#!/bin/bashsed -i "s/{{production}}/${PRODUCTION}/g" environment.tssed -i "s/{{api_url}}/${API_URL}/g" environment.tsexec $@