Created
September 25, 2019 09:25
-
-
Save max-weis/798a3fc15240784c0d810018ca2d6b20 to your computer and use it in GitHub Desktop.
Golang Multistage Dockerfile
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
# build stage | |
FROM golang:1.13-alpine as build | |
WORKDIR $GOPATH/app/ | |
RUN apk add git | |
# copy and download dependencies | |
COPY go.* . | |
RUN go mod download | |
#compile app | |
COPY . . | |
RUN CGO_ENABLED=0 GOOS=linux go build -o main | |
#resulting app | |
FROM scratch as final | |
COPY --from=build go/app/main /app/ | |
WORKDIR /app | |
EXPOSE 8080 | |
ENTRYPOINT [ "./main" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment