0

I was reading vue documents, and found this article: https://v2.vuejs.org/v2/cookbook/dockerize-vuejs-app.html?redirect=true#Real-World-Example

In this article, they wrote Dockerfile below:

# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
RUN npm run build

# production stage
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

My question is, why copy package*.json first separately? later on you do COPY . . which copies package.json again.

Why not just do COPY . . only and then do RUN npm install --production?

Guest-01
  • 587
  • 1
  • 4
  • 18

0 Answers0