Skip to content

Instantly share code, notes, and snippets.

@maxfunke
Created January 11, 2019 20:46
Show Gist options
  • Save maxfunke/e6f6586c61ddc29a38ec3d88c9e72e85 to your computer and use it in GitHub Desktop.
Save maxfunke/e6f6586c61ddc29a38ec3d88c9e72e85 to your computer and use it in GitHub Desktop.
multistage dockerfile
# Multistage build
FROM golang:alpine as build
## stage1: build app, make use of /go/src
RUN mkdir /go/src/app
WORKDIR /go/src/app
ADD ./src/main.go /go/src/app
RUN go build -o /bin/app
## stage2: bin to plain image
FROM scratch
COPY --from=build /bin/app /bin/app
ENTRYPOINT ["/bin/app"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment