11# Build the manager binary
2- FROM golang:1.25.3 -alpine AS builder
2+ FROM golang:1.25.7 -alpine AS builder
33ARG TARGETOS
44ARG TARGETARCH
55ARG VERSION=dev
@@ -8,9 +8,6 @@ ARG BUILD_DATE=unknown
88
99WORKDIR /workspace
1010
11- # Install ca-certificates for HTTPS calls in the final image
12- RUN apk add --no-cache ca-certificates
13-
1411# Copy the Go Modules manifests
1512COPY go.mod go.mod
1613COPY go.sum go.sum
@@ -21,16 +18,19 @@ RUN go mod download
2118COPY . .
2219
2320# Build with version info injected via ldflags
21+ # CGO_ENABLED=0 produces a fully static binary — no libc/OS dependencies
2422RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build \
2523 -ldflags="-s -w \
2624 -X github.com/aotanami/aotanami/internal/version.Version=${VERSION} \
2725 -X github.com/aotanami/aotanami/internal/version.Commit=${COMMIT} \
2826 -X github.com/aotanami/aotanami/internal/version.Date=${BUILD_DATE}" \
2927 -a -o manager cmd/main.go
3028
31- # Use distroless as minimal base image
32- # Refer to https://github.com/GoogleContainerTools/distroless for more details
33- FROM gcr.io/distroless/static-debian12:nonroot
29+ # ── Final stage: scratch (zero OS packages = zero OS CVEs) ──────────────────
30+ # Since the binary is statically compiled (CGO_ENABLED=0), we don't need any
31+ # OS libraries. Using scratch instead of distroless eliminates ALL OS-level
32+ # vulnerabilities from the image scan.
33+ FROM scratch
3434
3535# OCI Image Spec labels
3636# https://github.com/opencontainers/image-spec/blob/main/annotations.md
@@ -42,6 +42,10 @@ LABEL org.opencontainers.image.vendor="Zelyo AI"
4242LABEL org.opencontainers.image.licenses="Apache-2.0"
4343LABEL org.opencontainers.image.documentation="https://github.com/aotanami/aotanami/tree/main/docs"
4444
45+ # Copy CA certificates for TLS (Aotanami makes HTTPS calls to LLM APIs)
46+ COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
47+
48+ # Copy the statically-linked binary
4549WORKDIR /
4650COPY --from=builder /workspace/manager .
4751USER 65532:65532
0 commit comments