Skip to content

Instantly share code, notes, and snippets.

@Philmod
Last active October 10, 2017 21:13
Show Gist options
  • Save Philmod/59808b03b29193fc88497d6094b2a1b0 to your computer and use it in GitHub Desktop.
Save Philmod/59808b03b29193fc88497d6094b2a1b0 to your computer and use it in GitHub Desktop.
Builder pattern: one image to perform a build and another to have a lean runtime image, in a same Dockerfile.
# First Stage
FROM golang:1.6-alpine
RUN mkdir /app
ADD . /app/
WORKDIR /app
RUN go build -o main .
# Second Stage
FROM alpine
EXPOSE 8000
CMD ["/app"]
# Copy from first stage
COPY --from=0 /app/main /app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment