fix: include CA certificates in scratch Docker image#261
Open
patsevanton wants to merge 1 commit into
Open
Conversation
The final Docker image is built FROM scratch and does not contain system CA certificates. This causes TLS connections to Kafka brokers using public CA-signed certificates (e.g. AWS MSK with Amazon Trust Services) to fail with 'x509: certificate signed by unknown authority'. Copy ca-certificates.crt from the builder stage so that Go's crypto/tls can verify server certificates out of the box. Ref: sentry-kubernetes/charts#2213
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.
Problem
The final Docker image is built
FROM scratchand does not contain system CA certificates. When Go'scrypto/tlsattempts to verify a server certificate signed by a public CA (e.g. Amazon Trust Services for AWS MSK), it falls back to an empty root pool and fails with:This blocks all users connecting topicctl to Kafka clusters that use TLS with public-CA-signed certificates.
Ref: sentry-kubernetes/charts#2213
Fix
Copy
/etc/ssl/certs/ca-certificates.crtfrom the builder stage (golang:1.24.4, Debian-based) into thescratchfinal image. This is the standard Go approach for minimal container images — Go'scrypto/tlsautomatically discovers this file as the system root CA pool.The file is ~200KB and adds public CA trust (Amazon, DigiCert, Let's Encrypt, etc.) without adding an entire OS layer.
Before / After
test -f /etc/ssl/certs/ca-certificates.crt--tls-ca-cert)x509: unknown authorityTesting
Built and verified locally: