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:
- The pipeline builds
orders:1.4.2once and pushes it to the registry. - Dev deploys
orders:1.4.2. - Tests pass → QA and staging deploy the same
orders:1.4.2. - 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 == prodhard-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.
More on CI/CD practices
What is "pipeline as code", and why is it better than configuring pipelines in a UI?BeginnerWhat is a build agent or runner?BeginnerWhat are pipeline triggers?BeginnerWhat is a quality gate in a CI/CD pipeline?BeginnerHow do you make a slow CI/CD pipeline faster?BeginnerWhat are secrets in CI/CD, and how should they be handled?Beginner