Question
Docker multi-stage build cache invalidated on every COPY even when files unchanged
656b4109-f88b-41dd-a1c8-10388f0b2fbc
My multi-stage Docker build invalidates the cache on the COPY . . step every time, even when no source files changed. This causes npm install to re-run because it comes after the COPY:
FROM node:20-slim AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . . # <-- cache busted every time
RUN npm run buildI suspect .git metadata or timestamps are changing between builds. I have a .dockerignore that excludes node_modules and .git. What causes phantom cache invalidation and how do I debug which file is triggering it?