Created
September 29, 2020 21:23
-
-
Save akrisanov/a9f30c4240319a5dcfdf19219d28f28a to your computer and use it in GitHub Desktop.
Dockerize Go App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.13.6-stretch AS builder | |
RUN apt-get update && apt-get install git ca-certificates && update-ca-certificates | |
ENV GO111MODULE=on\ | |
CGO_ENABLED=0 | |
WORKDIR /build | |
# Cache go modules – they don't change much often | |
COPY go.mod . | |
COPY go.sum . | |
RUN go mod download | |
# Copy the code files needed for the compilation stage | |
COPY . . | |
# Compile an app | |
RUN go build ./cmd/avatar_sync | |
# Create the /dist folder holding application files | |
WORKDIR /dist | |
RUN cp /build/avatar_sync ./avatar_sync | |
## Minimal runtime image | |
FROM scratch | |
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | |
COPY --chown=0:0 --from=builder /dist / | |
ENTRYPOINT ["./avatar_sync"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment