diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..894a046a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +README.md +LICENSE +Makefile +dist/ +goreleaser.yml +openapi/ diff --git a/.travis.yml b/.travis.yml index 5b4059cc..eb93ecef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,6 @@ script: - docker build -t "$DOCKER_REPO" . - docker run -d --name stripe-mock-container -p 12111:12111 "$DOCKER_REPO" - docker ps -a - - docker exec -it stripe-mock-container /bin/sh -c "cd /go/src/github.com/stripe/stripe-mock/; go test ./..." deploy: provider: script diff --git a/Dockerfile b/Dockerfile index c7eb34fd..01a066d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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