generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 166
Expand file tree
/
Copy pathDockerfile
More file actions
30 lines (21 loc) · 863 Bytes
/
Dockerfile
File metadata and controls
30 lines (21 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Build go binaries
# See https://github.com/golang/go/issues/69255#issuecomment-2523276831
FROM --platform=$BUILDPLATFORM golang:1.26.1 AS builder
# Declare TARGETARCH to make it available in this build stage
ARG TARGETARCH
WORKDIR /workspace
# Download dependencies first to leverage layer caching
COPY go.mod go.sum ./
RUN go mod download
# Copy the code source needed
COPY api/ ./api/
COPY cmd/ ./cmd/
COPY controllers/ ./controllers/
COPY extensions/ ./extensions/
COPY internal/ ./internal/
# Build the binary with optimizations
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags="-s -w" -o /agent-sandbox-controller ./cmd/agent-sandbox-controller
# The controller image
FROM gcr.io/distroless/static-debian13:nonroot
COPY --from=builder /agent-sandbox-controller /agent-sandbox-controller
ENTRYPOINT ["/agent-sandbox-controller"]