docker build recreates every layer after a one line change
I've been fighting our Dockerfile cache for two days. Any source change makes npm ci run again, so builds went from 40 seconds to six minutes. Dockerfile is the usual: FROM node:20-slim, WORKDIR /app, COPY . ., RUN npm ci --omit=dev, RUN npm run build. BuildKit is on. I know COPY . . before the install is the problem, but moving it below COPY package*.json ./ sounds too simple to be the whole story. There's also a .dockerignore that might be wrong. What am I missing?
4 replies