Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions kagenti-operator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Build the manager binary
FROM docker.io/golang:1.26 AS builder
# Build the manager binary.
#
# `--platform=$BUILDPLATFORM` pins the builder stage to the host arch so
# Go cross-compiles to $TARGETARCH instead of running under QEMU. With
# CGO disabled (below), the resulting binary is bit-for-bit identical to
# a native build but ~9x faster for the arm64 variant.
FROM --platform=$BUILDPLATFORM docker.io/golang:1.26 AS builder
ARG TARGETOS
ARG TARGETARCH

Expand All @@ -21,7 +26,7 @@ COPY internal/ internal/
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This comment ("by leaving it empty we can ensure that the container and binary shipped on it will have the same platform") is now stale — it described the old approach of not pinning the builder platform. With --platform=$BUILDPLATFORM on line 7, the builder IS explicitly pinned to host arch and Go cross-compiles via GOARCH=${TARGETARCH}. The new comment at the top of the file explains the correct rationale. Consider removing or updating these three lines to avoid contradicting the new approach.

RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -o manager cmd/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
8 changes: 6 additions & 2 deletions kagenti-operator/cmd/agentcard-signer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM docker.io/golang:1.26 AS builder
# `--platform=$BUILDPLATFORM` pins the builder stage to the host arch so
# Go cross-compiles to $TARGETARCH instead of running under QEMU. With
# CGO disabled (below), the resulting binary is bit-for-bit identical to
# a native build but ~9x faster for the arm64 variant.
FROM --platform=$BUILDPLATFORM docker.io/golang:1.26 AS builder
ARG TARGETOS
ARG TARGETARCH

Expand All @@ -11,7 +15,7 @@ COPY cmd/agentcard-signer/ cmd/agentcard-signer/
COPY api/ api/
COPY internal/ internal/

RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o agentcard-signer ./cmd/agentcard-signer/
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -o agentcard-signer ./cmd/agentcard-signer/

FROM gcr.io/distroless/static:nonroot
WORKDIR /
Expand Down
8 changes: 6 additions & 2 deletions kagenti-operator/cmd/test-tls-agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM docker.io/golang:1.26 AS builder
# `--platform=$BUILDPLATFORM` pins the builder stage to the host arch so
# Go cross-compiles to $TARGETARCH instead of running under QEMU. With
# CGO disabled (below), the resulting binary is bit-for-bit identical to
# a native build but ~9x faster for the arm64 variant.
FROM --platform=$BUILDPLATFORM docker.io/golang:1.26 AS builder
ARG TARGETOS
ARG TARGETARCH

Expand All @@ -11,7 +15,7 @@ COPY cmd/test-tls-agent/ cmd/test-tls-agent/
COPY api/ api/
COPY internal/ internal/

RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o test-tls-agent ./cmd/test-tls-agent/
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -o test-tls-agent ./cmd/test-tls-agent/

FROM gcr.io/distroless/static:nonroot
WORKDIR /
Expand Down
Loading