this repo has no description
1# Build the manager binary
2FROM golang:1.24 AS builder
3ARG TARGETOS
4ARG TARGETARCH
5
6WORKDIR /workspace
7# Copy the Go Modules manifests
8COPY go.mod go.mod
9COPY go.sum go.sum
10# cache deps before building and copying source so that we don't need to re-download as much
11# and so that source changes don't invalidate our downloaded layer
12RUN go mod download
13
14# Copy the go source
15COPY cmd/main.go cmd/main.go
16COPY api/ api/
17COPY internal/ internal/
18
19# Build
20# the GOARCH has not a default value to allow the binary be built according to the host where the command
21# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
22# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
23# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
24RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
25
26# Use distroless as minimal base image to package the manager binary
27# Refer to https://github.com/GoogleContainerTools/distroless for more details
28FROM gcr.io/distroless/static:nonroot
29WORKDIR /
30COPY --from=builder /workspace/manager .
31USER 65532:65532
32
33ENTRYPOINT ["/manager"]