github.com/kotalco/kotal@v0.3.0/Dockerfile (about)

     1  # Build the manager binary
     2  FROM golang:1.21 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 apis/ apis/
    15  COPY clients/ clients/
    16  COPY controllers/ controllers/
    17  COPY helpers/ helpers/
    18  
    19  # Build
    20  RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
    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"]