Interview Prep/CI/CD/Fundamentals and Pipeline Design

Explain "build once, deploy many". Why is rebuilding per environment an anti-pattern?

IntermediateConceptFundamentals and Pipeline Design
Answer

You build the artifact a single time, tag it with an immutable identifier (commit SHA or image digest), and promote that same artifact through dev, staging and production. Only configuration changes between environments, injected at deploy time (env vars, ConfigMaps, Helm values).

Rebuilding per environment means production runs bits that were never tested, because compilers, dependency resolution or base images may have changed in between. It also makes "it passed in staging" meaningless.

docker build -t registry.example.com/shop/api:${GIT_SHA} .
docker push registry.example.com/shop/api:${GIT_SHA}
# staging and prod deploy the SAME tag; only values files differ
helm upgrade --install api ./chart -f values-prod.yaml --set image.tag=${GIT_SHA}
All CI/CD questions Roadmap: CI/CD fundamentals

More on Fundamentals and Pipeline Design