Reputation: 11
I'm using nginx:alpine docker image.
I try to do the compilation process in Dockerfile, and it generates a folder named dist in the docker container.
At the last step, I try to copy the generated dist folder to /usr/share/nginx/html as instructed in https://hub.docker.com/_/nginx/
What I have tried is:
# Copy dist folder to destination
RUN cp -rf dist /usr/share/nginx/html/
But the result is that when I run the image, the nginx displays the default nginx page.
I have also tried to compile before I run docker build, and at the last step of Dockerfile:
COPY dist /user/share/nginx/html
And this time it works.
Any idea how I can do the compilation in Dockerfile while I can successfully copy the generated dist folder to destination?
Upvotes: 1
Views: 3266
Reputation: 1324148
Maybe try to use two nginx:alpine images (in the same Dockerfile):
This is described as a multi-stage build.
Upvotes: 1