Interview Prep/Docker/Build Performance & CI

How do you make Docker builds fast in CI where runners are ephemeral?

BeginnerProductionBuild Performance & CI
Answer

Export and import the BuildKit cache from a registry or CI cache backend.

docker buildx build \
  --cache-from type=registry,ref=reg.example.com/app:buildcache \
  --cache-to   type=registry,ref=reg.example.com/app:buildcache,mode=max \
  -t reg.example.com/app:$GIT_SHA --push .

mode=max also caches intermediate stages. On GitHub Actions use type=gha.

All Docker questions Roadmap: Docker & containers

More on Build Performance & CI