Interview Prep/CI/CD/GitHub Actions and GitLab CI in Production

How do you optimise Docker builds in GitHub Actions for a large monorepo image?

IntermediateProductionGitHub Actions and GitLab CI in Production
Answer

Use BuildKit with a registry cache (type=registry,mode=max) or the GHA cache, structure the Dockerfile for layer reuse (dependency manifests first), use --mount=type=cache for package manager caches, build only changed services, and build multi-arch with QEMU only when needed (or use native ARM runners instead of emulation, which is dramatically faster). Check where time goes with docker buildx build --progress=plain.

RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt
All CI/CD questions Roadmap: GitLab CI/CD

More on GitHub Actions and GitLab CI in Production