Build Docker with angular Node

Asked

Viewed 215 times

0

I need a little help with Docker, I need to build to generate an image, but I’m having the following error:

Step 9/10 : COPY --from=angular /app/dist/Docker-softplayer /usr/share/Nginx/html ERROR: Service 'softplayer-angular' failed to build : COPY failed: stat /var/lib/Docker/overlay2/487f7260d0a1b1134efd0cf9c5c2da21697ccaf2354f64ee971dc3c1c78e5d2e/merged/app/dist/Docker-softplayer: no such file or directory The terminal process "C: Windows System32 cmd.exe /d /c Docker-Compose up -d --build" terminated with Exit code: 1.

The error until it is very clear, it says that it did not find any file or directory with that name in Nginx, the problem is that if I remove the COPY that generates this error it builda, but it appears only the Nginx Welcome screen, then I saw a tutorial from Loyane where she says to use this COPY and so I use it, it is the first time that I get a Docker image so I do not understand much of the technical parts, but I have seen that there is the Docker-ignore that could cause this error, but I already assume that I don’t use this Docker-ignore, the name of my application in package.json is Docker-softplayer.

My Dockerfile:

FROM node:10 as angular
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . .
RUN npm run build --prod

FROM nginx:alpine
VOLUME /var/cache/nginx
COPY --from=angular /app/dist/docker-softplayer /usr/share/nginx/html
COPY ./config/nginx.conf /etc/nginx/conf.d/default.conf

Can someone help me with this please?

1 answer

0

I adjusted my Dockerfile as follows and solved my problem:

FROM node:10 as angular
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . .
RUN npm run build --prod

FROM nginx:alpine
VOLUME /var/cache/nginx
RUN rm -rf /usr/share/nginx/html/*
COPY --from=angular /app/dist /usr/share/nginx/html
COPY ./config/nginx.conf /etc/nginx/conf.d/default.conf

Browser other questions tagged

You are not signed in. Login or sign up in order to post.