-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from stripe/brandur-leaner-docker
Leaner Docker image through the use of multi-stage builds
- Loading branch information
Showing
3 changed files
with
31 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
README.md | ||
LICENSE | ||
Makefile | ||
dist/ | ||
goreleaser.yml | ||
openapi/ |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,29 @@ | ||
FROM golang:1.9-alpine | ||
# -*- mode: dockerfile -*- | ||
# | ||
# A multi-stage Dockerfile that builds a Linux target then creates a small | ||
# final image for deployment. | ||
|
||
ADD . /go/src/github.com/stripe/stripe-mock | ||
# | ||
# STAGE 1 | ||
# | ||
# Uses a Go image to build a release binary. | ||
# | ||
|
||
RUN go install github.com/stripe/stripe-mock | ||
FROM golang:1.9-alpine AS builder | ||
WORKDIR /go/src/github.com/stripe/stripe-mock/ | ||
ADD ./ ./ | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o stripe-mock . | ||
|
||
EXPOSE 12111 | ||
# | ||
# STAGE 2 | ||
# | ||
# Use a tiny base image (alpine) and copy in the release target. This produces | ||
# a very small output image for deployment. | ||
# | ||
|
||
ENTRYPOINT /go/bin/stripe-mock | ||
FROM alpine:latest | ||
RUN apk --no-cache add ca-certificates | ||
WORKDIR / | ||
COPY --from=builder /go/src/github.com/stripe/stripe-mock/stripe-mock . | ||
ENTRYPOINT /stripe-mock | ||
EXPOSE 12111 |