I have a React App running using Docker. I want to deploy the same docker image on dev, staging and prod environment.
The value of my React environment variable (REACT_APP_PARAM) is different for each environment.
My dockerfile look like this :
…
COPY . .
ARG REACT_APP_PARAM
ENV REACT_APP_PARAM $ REACT_APP_PARAM
…
I use this Dockecompose file to build my image
version: "3"
services:
frontend:
image: my-image
build:
context: .
args:
- REACT_APP_PARAM=BuildParam
environment:
- REACT_APP_PARAM=${REACT_APP_PARAM}
ports:
- "80"
- "443"
When deploy and run my image on dev environment I use this dockercompose file
version: "3"
services:
frontend:
image: my-image
restart: always
environment:
- REACT_APP_PARAM=DevelopmentParam
ports:
- "80"
- "443"
When I debug my application the value of REACT_APP_PARAM is still BuildParam
But went I list my container environment variable with command docker exec my-image env, the value of REACT_APP_PARAM is DevelopmentParam.
Any ideas how I can solve this or how is the best approach to archive that?
Thanks