Is it possible to pass an env from an docker-compose.yml file to dockerfile.
I have inside the dockerfile like this:
RUN $(npm bin)/ng build --prod --env=prod
But what I want is when the docker-compose.yml has a build_env that is:
environment:
BUILD_ENV: 'test'
Then I want the docker
RUN $(npm bin)/ng build --prod --env=test
How do I achieve something like this? Or are there any other better solutions to do this?
You can review this documentation:
https://docs.docker.com/compose/compose-file/#args
build:
context: .
args:
- buildno=1
- password=secret
- buildenv=prod
-
ARG buildno
ARG password
ARG buildenv
RUN echo "Build number: $buildno"
RUN script-requiring-password.sh "$password"
RUN $(npm bin)/ng build --prod --env="$buildenv"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.