How does multi-stage build looks like

tags: learning programming

content

in a Dockerfile, each FROM represents a stage

# Stage 1: Build stage
FROM node:18 AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
 
# Stage 2: Production stage
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
  • the artifacts from Stage 1 is /app/dist, that’s where npm leaves its build artifacts

up

down

reference