Skip to the page

CI/CD and infrastructure as code · mid

Designing and speeding up CI pipelines

A good pipeline builds once, caches well, tests only what changed, and promotes the same image through environments. Slow pipelines are fixed by measuring first.

The notes

What you must know

  • Measure first: stage timings, queue time versus run time, and a fast build compared with a slow one.
  • Typical cause of a sudden slowdown: moving to throwaway agents with empty caches, so every build downloads all dependencies and builds with no layer cache, and pulls base images from a rate-limited registry.
  • Fixes: a dependency proxy in the same network, BuildKit cache exported to a registry, a base image mirror, and cache keys based on lock files.
  • Pull request: build and test only affected services (path filters), lint, unit tests, dependency scan, build the image without pushing, and render and policy-check manifests.
  • Merge to main: build once, tag with the Git SHA, push, sign, scan and deploy to dev. Promote the same image digest to staging and production. Production never gets a rebuilt image.
  • Environments differ only in config. Gates between them can be tests, approvals and metrics checks.
  • A containerised service pipeline uses pull_request for checks and push to main for build and deploy, with cache and OIDC to the registry.
  • Track pipeline duration and failure rate as a team metric.

The red pen

Common traps: mistake → fix

  • Mistake: Rebuild the image for each environment

    Fix: promote the same digest.

  • Mistake: More parallel runners fix a slow pipeline

    Fix: measure, then fix cache and waste.

  • Mistake: Run everything on every change

    Fix: use path filters in a monorepo.

Easy to hard

Questions interviewers ask, easy to hard

  1. Our pipeline went from 8 minutes to 40. Where do you start?
  2. Design CI/CD for 20 microservices in a monorepo.
  3. Write a pipeline for a Node.js service: PR checks and image push on merge.
  4. Why tag with the Git SHA?

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview