| Giorgi Lekveishvili | 7366dbb | 2023-06-16 12:31:03 +0400 | [diff] [blame] | 1 | # Build the manager binary |
| 2 | FROM golang:1.18 as builder |
| 3 | |
| 4 | WORKDIR /workspace |
| 5 | # Copy the Go Modules manifests |
| 6 | COPY go.mod go.mod |
| 7 | COPY 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 |
| 10 | RUN go mod download |
| 11 | |
| 12 | # Copy the go source |
| 13 | COPY main.go main.go |
| 14 | COPY api/ api/ |
| 15 | COPY controllers/ controllers/ |
| 16 | |
| 17 | # Build |
| Giorgi Lekveishvili | 44f9d59 | 2023-06-21 14:58:19 +0400 | [diff] [blame^] | 18 | RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -o manager main.go |
| Giorgi Lekveishvili | 7366dbb | 2023-06-16 12:31:03 +0400 | [diff] [blame] | 19 | |
| 20 | # Use distroless as minimal base image to package the manager binary |
| 21 | # Refer to https://github.com/GoogleContainerTools/distroless for more details |
| 22 | FROM gcr.io/distroless/static:nonroot |
| 23 | WORKDIR / |
| 24 | COPY --from=builder /workspace/manager . |
| 25 | USER 65532:65532 |
| 26 | |
| 27 | ENTRYPOINT ["/manager"] |