Cache the package manager's store across builds with a mount
A layer cache is all or nothing: change the lockfile and the whole install reruns from the network. A cache mount keeps the store between builds.
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfileThe install still runs, but it links from the local store instead of downloading. Same trick for pip, cargo and go caches.
dockerci