Skip to content

Instantly share code, notes, and snippets.

@zombiezen
Last active April 3, 2019 22:16
Show Gist options
  • Save zombiezen/9f923cf8a8ca10c9af38068aa1d8f0a2 to your computer and use it in GitHub Desktop.
Save zombiezen/9f923cf8a8ca10c9af38068aa1d8f0a2 to your computer and use it in GitHub Desktop.
Go Modules Dockerfile
FROM golang:1.12 AS build
COPY go.mod go.sum m/
RUN cd m && go mod download
COPY . srcroot
RUN cd srcroot && go install -mod=readonly ./cmd/foo \
&& go clean -modcache -cache std
FROM debian:stretch-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build /go/bin/foo /usr/bin/foo
ENTRYPOINT ["/usr/bin/foo"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment