Skip to content

Predict the rebuild

A Dockerfile and one stated edit. Mark each instruction as cached or rebuilt before anything runs. Then it runs.

The Dockerfile everybody writes first

One line changes in one source file. Mark every instruction you think will run again.

The editedit src/routes.js

  • 1FROM alpine:3.22
  • 2WORKDIR /app
  • 3COPY . .
  • 4RUN npm ci
  • 5RUN npm run build
  • 6CMD ["node", "src/server.js"]

Nothing has run

Mark every instruction, then build. The ledger, the layers and the reasons appear together — not before.