Home > other >  Angular Docker File dist not found
Angular Docker File dist not found

Time:07-19

I'm trying to Dockerize an Angular project This is my Dockerfile:

# 1. Build our Angular app
FROM node:12 as builder

WORKDIR /app
COPY package.json package-lock.json ./
ENV CI=1
RUN npm ci

COPY . .
RUN npm run build-web --output-path=/dist
RUN ls

# 2. Deploy our Angular app to NGINX
FROM nginx:alpine

## Replace the default nginx index page with our Angular app
RUN rm -rf /usr/share/nginx/html/* 
COPY --from=builder /dist /usr/share/nginx/html

COPY ./.nginx/nginx.conf /etc/nginx/nginx.conf

ENTRYPOINT ["nginx", "-g", "daemon off;"]

But there is an error:

[stage-1 3/4] COPY --from=builder /dist /usr/share/nginx/html:                                                                                                                                           

What is the problem?

CodePudding user response:

In the building state, your working directory is "/app", all of your files are under the "/app" directory.

In the second state, you try to copy a file from "/dist", Change path of the source file from "/dist" to "/app/dist"

COPY --from=builder /app/dist /usr/share/nginx/html
  • Related