| Giorgi Lekveishvili | 2d843c3 | 2023-07-20 10:10:24 +0400 | [diff] [blame] | 1 | # # Build the manager binary |
| 2 | # FROM golang:1.18 as builder |
| Giorgi Lekveishvili | b591eae | 2023-06-16 12:31:49 +0400 | [diff] [blame] | 3 | |
| Giorgi Lekveishvili | 2d843c3 | 2023-07-20 10:10:24 +0400 | [diff] [blame] | 4 | # ARG TARGETARCH |
| Giorgi Lekveishvili | 0ccd148 | 2023-06-21 15:02:24 +0400 | [diff] [blame] | 5 | |
| Giorgi Lekveishvili | 2d843c3 | 2023-07-20 10:10:24 +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 |
| Giorgi Lekveishvili | b591eae | 2023-06-16 12:31:49 +0400 | [diff] [blame] | 13 | |
| Giorgi Lekveishvili | 2d843c3 | 2023-07-20 10:10:24 +0400 | [diff] [blame] | 14 | # # Copy the go source |
| 15 | # COPY main.go main.go |
| 16 | # COPY api/ api/ |
| 17 | # COPY controllers/ controllers/ |
| Giorgi Lekveishvili | b591eae | 2023-06-16 12:31:49 +0400 | [diff] [blame] | 18 | |
| Giorgi Lekveishvili | 2d843c3 | 2023-07-20 10:10:24 +0400 | [diff] [blame] | 19 | # # Build |
| 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 | |
| Giorgi Lekveishvili | 2d843c3 | 2023-07-20 10:10:24 +0400 | [diff] [blame] | 22 | # # Use distroless as minimal base image to package the manager binary |
| 23 | # # Refer to https://github.com/GoogleContainerTools/distroless for more details |
| Giorgi Lekveishvili | b591eae | 2023-06-16 12:31:49 +0400 | [diff] [blame] | 24 | FROM gcr.io/distroless/static:nonroot |
| Giorgi Lekveishvili | 2d843c3 | 2023-07-20 10:10:24 +0400 | [diff] [blame] | 25 | ARG TARGETARCH |
| Giorgi Lekveishvili | b591eae | 2023-06-16 12:31:49 +0400 | [diff] [blame] | 26 | WORKDIR / |
| Giorgi Lekveishvili | 2d843c3 | 2023-07-20 10:10:24 +0400 | [diff] [blame] | 27 | COPY manager_${TARGETARCH} manager |
| Giorgi Lekveishvili | b591eae | 2023-06-16 12:31:49 +0400 | [diff] [blame] | 28 | USER 65532:65532 |
| 29 | |
| 30 | ENTRYPOINT ["/manager"] |