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
More on GitHub Actions and GitLab CI in Production
How do you organise reusable workflows for an organisation on GitHub?IntermediateHow do you reduce GitHub Actions minutes cost on private repos?IntermediateHow do you secure self-hosted runners?AdvancedHow do you design the GitHub Actions OIDC trust policy for AWS safely?AdvancedHow do you handle approvals and deployments across environments in GitHub Actions?IntermediateHow do you handle required checks when workflows use path filters or matrices?Advanced