What is "build once, deploy many", and why is it important?

IntermediateConceptCI/CD practices
Answer

In one line: "Build once, deploy many" means you build the artifact a single time, then deploy that exact same artifact to every environment — dev, QA, staging and production — changing only configuration.

The wrong way: rebuilding from source for each environment.

  • Dependencies can change between builds (a new library version is released).
  • Build tools or base images can change.
  • So production could get code that was never actually tested in staging.

The right way:

  1. The pipeline builds orders:1.4.2 once and pushes it to the registry.
  2. Dev deploys orders:1.4.2.
  3. Tests pass → QA and staging deploy the same orders:1.4.2.
  4. Production deploys the same orders:1.4.2.

What changes between environments: configuration only

  • Environment variables, ConfigMaps, Helm values files (values-dev.yaml, values-prod.yaml).
  • Secrets from a vault per environment.
  • Feature flags.

What this requires:

  • Externalised configuration — no environment-specific values baked into the image (no if env == prod hard-coded URLs).
  • Immutable artifacts — tags are never overwritten; ideally deploy by image digest (orders@sha256:...), which can't change.
  • Artifact promotion — the pipeline promotes a version from one environment to the next, rather than building again.

Benefits:

  • What you tested is exactly what you release.
  • Faster deployments (no rebuild).
  • Clear traceability: production runs 1.4.2, built from commit 3f9c2ab.
  • Easy rollback to any earlier artifact.

Example: a Helm deploy for staging and production uses the same image.tag=1.4.2 with different values files for replicas, URLs and resource limits.

Tip for interviews: mention immutable tags, image digests and externalised configuration — that shows you understand how to actually implement it.

All DevOps Fundamentals questions

More on CI/CD practices