Created
March 6, 2019 00:10
-
-
Save jasonkeene/c3291296c0c93bb741b0f2be8d92682d to your computer and use it in GitHub Desktop.
Go Modules Dockerfile
This file contains 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.12 as builder | |
WORKDIR /root | |
ENV GOOS=linux \ | |
GOARCH=amd64 \ | |
CGO_ENABLED=0 | |
COPY /go.mod /go.sum /root/ | |
RUN go version && \ | |
go mod download | |
COPY / /root/ | |
RUN go build \ | |
-a \ | |
-installsuffix nocgo \ | |
-o /your_program \ | |
-mod=readonly \ | |
your/package | |
FROM scratch | |
COPY --from=builder /your_program /srv/ | |
WORKDIR /srv | |
CMD [ "/srv/your_program" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment