Skip to content

Commit 49335f9

Browse files
authored
build: Upgrade Go version to 1.25.7 and switch Docker final image to scratch. (#5)
* build: Upgrade Go version to 1.25.7 and switch Docker final image to scratch. * Remove copying of timezone data and passwd file from the builder stage in Dockerfile.
1 parent 06b407b commit 49335f9

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

Dockerfile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.25.3-alpine AS builder
2+
FROM golang:1.25.7-alpine AS builder
33
ARG TARGETOS
44
ARG TARGETARCH
55
ARG VERSION=dev
@@ -8,9 +8,6 @@ ARG BUILD_DATE=unknown
88

99
WORKDIR /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
1512
COPY go.mod go.mod
1613
COPY go.sum go.sum
@@ -21,16 +18,19 @@ RUN go mod download
2118
COPY . .
2219

2320
# Build with version info injected via ldflags
21+
# CGO_ENABLED=0 produces a fully static binary — no libc/OS dependencies
2422
RUN 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"
4242
LABEL org.opencontainers.image.licenses="Apache-2.0"
4343
LABEL 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
4549
WORKDIR /
4650
COPY --from=builder /workspace/manager .
4751
USER 65532:65532

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/aotanami/aotanami
22

3-
go 1.25.3
3+
go 1.25.7
44

55
require (
66
github.com/onsi/ginkgo/v2 v2.27.2

0 commit comments

Comments
 (0)