Good Code
The good version lets the dependency install layer stay cached when only source files change.
Lesson 03
Order Dockerfile instructions so dependency layers are reused when source files change.
FROM node:22-alpine AS app
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY src ./src
COPY public ./public
RUN npm run buildFROM node:22-alpine AS app
WORKDIR /app
COPY . .
RUN npm install
RUN npm run buildThe good version lets the dependency install layer stay cached when only source files change.
The bad version copies the whole project before installing dependencies. Any source edit can invalidate the expensive install layer.