절대 하지 말아야 할 것 셋
- Dockerfile 에
ENV API_KEY=...— secret 을 image 의 layer 에 굽는 거. image 가진 사람이 키 가짐. - git 에 commit 한 compose.yaml 의 하드코딩
environment:— secret 이 영원히 repo 히스토리에. - 런타임 용도에
--build-arg로 secret 전달 — ARG 값이 image build 히스토리에 보임.
해야 할 것 셋
- 로컬 dev:
.env파일 compose 가 참조,.env는.gitignore에. - CI/CD: pipeline 이 secret 을 런타임 환경에 주입 (GitHub Actions secrets, GitLab CI variables), image 에 X.
- Production: 진짜 secrets manager (AWS Secrets Manager, GCP Secret Manager, HashiCorp Vault, k8s 의 sealed-secrets) — 시작 시 fetch, 디스크에 안 씀.