blob: 5a355c2148925aff8e29be8a58173fe525e910db [file] [log] [blame]
Giorgi Lekveishvili7366dbb2023-06-16 12:31:03 +04001# Build the manager binary
2FROM golang:1.18 as builder
3
4WORKDIR /workspace
5# Copy the Go Modules manifests
6COPY go.mod go.mod
7COPY go.sum go.sum
8# cache deps before building and copying source so that we don't need to re-download as much
9# and so that source changes don't invalidate our downloaded layer
10RUN go mod download
11
12# Copy the go source
13COPY main.go main.go
14COPY api/ api/
15COPY controllers/ controllers/
16
17# Build
18RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
19
20# Use distroless as minimal base image to package the manager binary
21# Refer to https://github.com/GoogleContainerTools/distroless for more details
22FROM gcr.io/distroless/static:nonroot
23WORKDIR /
24COPY --from=builder /workspace/manager .
25USER 65532:65532
26
27ENTRYPOINT ["/manager"]