From c1817e2ef10d9556b1da93fc83c20e5d6bea7e56 Mon Sep 17 00:00:00 2001 From: Jinn Koriech Date: Wed, 2 Jan 2019 17:02:43 +0000 Subject: [PATCH] Introduce Dockerfile for quick easy serving We use a multi-stage build so we don't ship the entire repo, we only ship the resulting binary, which we run via dumb-init to ensure proper signal handling in the container. --- Dockerfile | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9f1beeb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# build image + +FROM golang:alpine AS build + +WORKDIR /go/src/github.com/rdegges/ipify-api +COPY . /go/src/github.com/rdegges/ipify-api +RUN go build + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] +CMD ["/go/src/github.com/rdegges/ipify-api/ipify-api"] + +# live image + +FROM build AS live +EXPOSE 3000/tcp + +RUN apk upgrade \ + && apk add --update dumb-init \ + && rm /var/cache/apk/* + +COPY --from=build /go/src/github.com/rdegges/ipify-api/ipify-api /go/bin/ + +CMD ["/go/bin/ipify-api"]