beginnerImages, Layers, Caching & Container Lifecycle
Cache never hits in CI even though source code didn't change
Every CI build re-runs `npm install` from scratch even when package.json is identical to the last commit. What would you check? Expected reasoning: confirm COPY package.json comes before COPY . . in the Dockerfile; check whether the CI uses --no-cache or a fresh build context each time (e.g., shallow clone changing file timestamps/hashes unexpectedly, or CI not persisting the Docker build cache between jobs — may need BuildKit's --cache-from/--cache-to or registry cache export).
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response