github.com/metaprov/modela-operator@v0.0.0-20240118193048-f378be8b74d2/Dockerfile (about)

     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  
    13  ENV K8S_VERSION=v1.24.1
    14  ENV HELM_VERSION=v3.9.0
    15  ENV HELM_FILENAME=helm-${HELM_VERSION}-linux-amd64.tar.gz
    16  
    17  # install helm and kubectl
    18  RUN curl -L https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl 
    19  RUN curl -L https://get.helm.sh/${HELM_FILENAME} | tar xz && mv linux-amd64/helm /bin/helm && rm -rf linux-amd64
    20  # Copy the go source
    21  COPY main.go main.go
    22  COPY api/ api/
    23  COPY controllers/ controllers/
    24  COPY pkg/ pkg/
    25  
    26  # Build
    27  RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
    28  
    29  # Use distroless as minimal base image to package the manager binary
    30  # Refer to https://github.com/GoogleContainerTools/distroless for more details
    31  FROM alpine/git
    32  WORKDIR /
    33  
    34  COPY manifests /manifests
    35  COPY assets /assets
    36  COPY --from=builder /workspace/manager .
    37  COPY --from=builder /usr/local/bin/kubectl /usr/local/bin/
    38  COPY --from=builder /bin/helm /usr/local/bin/
    39  
    40  
    41  ENTRYPOINT ["/manager"]