Dockerfile 776 B

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