I have a Angular app made using angular-cli.
I have made a Dockerfile:
FROM ngnix
COPY dist /usr/share/ngnix/html
EXPOSE 80
Now I want to deploy this image in minikube
, and also I want to print the Environment variable I passed via kubectl apply
in the index.html
My problem is how my Angular App will have the access to Environment Variable.
Suppose, you are deploying following Pod in minikube to run your app.
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: myapp
image: app/angular
env:
- name: ENV_1
value: "value 1"
- name: ENV_2
value: "value 2"
Lets say, this container will run your app.
Your question:
How can you get these ENV inside your Container?
Answer:
There is nothing special to do to get these ENVs. All ENVs, you have passed, are now your systems ENV. You can just get them.
In Bash: echo $ENV_1 $ENV_2
If you want to print them: printenv
in bash.
Hope this will help