Skip to content

Instantly share code, notes, and snippets.

Last active June 30, 2020 23:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
# Build the manager binary
FROM golang:1.13 as builder
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# Make go mod works with private gilab
RUN git config --global http.sslVerify false
RUN git config --global \
url."".insteadOf \
RUN GIT_TERMINAL_PROMPT=1 go get -v -insecure
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
# Copy the go source
COPY main.go main.go
COPY webhooks/ webhooks/
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
# Use distroless as minimal base image to package the manager binary
COPY --from=builder /workspace/manager .
USER nonroot:nonroot
ENTRYPOINT ["/manager"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment