Chapter 4. Golden Container Images
Pre-reqs
app/Dockerfile.basewith placeholder digests- Cosign keypair (
cosign generate-key-pair) - Kyverno installed (optional enforcement)
Steps
Pin base image digests (once)
make pin-digests # paste the printed digests into app/Dockerfile.base ARGsBuild + secure the golden base
make golden-imageThis runs:
base-build→ builds$(IMAGE_REPO):base-$(TAG)and:base-latestbase-scan→ Trivy →artifacts/trivy-image-base.jsonbase-sbom→ Syft →artifacts/sbom-base.jsonbase-sign/base-verify→ Cosign bundle →artifacts/sbom-base.bundle,artifacts/cosign-verify-base.txt
(Optional) Enforce org-only images at admission
make kyverno-apply-allow-org make kyverno-test-allow-orgEvidence:
artifacts/policy-allow-org-test.txt
Verify
Check artifacts exist:
Run
make evidence(your ZIP now includes the golden artifacts).
Makefile commands
- One-shot:
make golden-image - Policy apply/test:
make kyverno-apply-allow-org/make kyverno-test-allow-org - Optional CI:
make ci INCLUDE_GOLDEN=1 KYVERNO_ENFORCE_ORG=1
Checklist
- Base Dockerfile pinned by digest
- Golden image built and scanned
- SBOM generated and signed
- (Optional) Kyverno org-allow policy applied & tested
- Evidence ZIP contains base scan/SBOM/signature + policy test