This is my dockerFile located at vDocker/Dockerfile
# build stage
FROM node:lts-alpine as build-stage
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# production stage
FROM nginx:stable-alpine as production-stage
RUN apk add –no-cache bash
COPY ./vDocker/nginx.conf /etc/nginx/conf.d/default.conf
COPY –from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80 443
CMD [“nginx”, “-g”, “daemon off;”]
I also have docker-compose located at root directory.
After running docker-compose build, It gives me the following error: Service ‘web_client’ failed to build: COPY failed: stat /var/lib/docker/overlay2/67b326c995a1ce52fb3ee2a792d84ffe9bc403aa5962755a2b89f1ab925a1242/merged/app/dist: no such file or directory
Any idea why?
You don’t need to name the second stage.
How the build looks like depends on how you set it up and I don’t know it. But what you can do is:
run the first stage as a separate Dockerfile
after the last RUN add RUN ls -lart -> this should print the contents of the directory and you can check if the /app/dist really exists
For the rest the code looks good.