Use distroless base image for runtime container images#7637
Open
CharlieTLe wants to merge 1 commit into
Open
Conversation
Switch the cortex, query-tee, thanosconvert, and test-exporter runtime images from alpine:3.23 to gcr.io/distroless/static-debian12. The binaries are fully static (CGO_ENABLED=0, netgo), so they have no shell or libc dependency at runtime. CA certificates are bundled in the distroless image, so the apk ca-certificates install is dropped. The image continues to run as root (uid 0) so the default HTTP listen port 80 keeps binding. Signed-off-by: Charlie Le <charlie_le@apple.com>
ed2b204 to
05bb32d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Switches the runtime container images from
alpine:3.23togcr.io/distroless/static-debian12for all four runtime binaries:cmd/cortex/Dockerfilecmd/query-tee/Dockerfilecmd/thanosconvert/Dockerfilecmd/test-exporter/DockerfileThe Cortex binaries are already built fully static and CGO-free (
CGO_ENABLED=0,-extldflags "-static" -tags "netgo slicelabels"), so they have no shell or libc dependency at runtime — a clean fit for distroless. This reduces image size and attack surface (no shell, no package manager, no busybox).Notes
gcr.io/distroless/static-debian12(/etc/ssl/certs/ca-certificates.crt), so theapk add --no-cache ca-certificatesstep is dropped. TLS to object storage (S3/GCS/etc.) continues to work.:nonrootvariant. Cortex's defaultserver.http-listen-portis80, a privileged port; staying root keeps the default config and the integration tests (which bind port 80) working with no breaking change. The base image is exposed as an overridableBASEIMGARG so CI can pin to an immutable digest./readyreadiness probe.Checklist