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