Skip to content

Instantly share code, notes, and snippets.

@gosharplite
Last active June 30, 2020 23:56
Show Gist options
  • Save gosharplite/3f257f7842d3f55b1a60e91ff66262ab to your computer and use it in GitHub Desktop.
Save gosharplite/3f257f7842d3f55b1a60e91ff66262ab to your computer and use it in GitHub Desktop.
# 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."https://tonyhsu:[email protected]".insteadOf \
"https://gitlab.devops.maaii.com"
RUN GIT_TERMINAL_PROMPT=1 go get -v -insecure gitlab.devops.maaii.com/cloud-native/stagenamespace
# 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
FROM gcr.io/distroless/static:nonroot
WORKDIR /
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