How do you manage application secrets from build to runtime?
IntermediateProductionSecrets and Credentials
Answer
Keep secrets out of the image and out of Git. Build-time secrets (private registry token) are passed with BuildKit --secret so they never land in a layer. Runtime secrets are fetched by the platform: External Secrets Operator or the Secrets Store CSI driver syncing from AWS Secrets Manager/Vault into Kubernetes, or IRSA/Workload Identity so the app reads the secret manager directly. The pipeline only references secret names, never values.
docker build --secret id=npmrc,src=$HOME/.npmrc -t api:$GIT_SHA .
# Dockerfile: RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm ci
More on Secrets and Credentials
Why are long-lived credentials in CI a problem, and what is the modern alternative?BeginnerHow do you store secrets in Git safely for GitOps?IntermediateHow do you detect secrets committed to a repo?BeginnerWhat do you do after a secret is committed to Git?IntermediateHow do you use HashiCorp Vault with CI/CD?AdvancedHow do you rotate a credential used by dozens of pipelines without downtime?Advanced