From b70e868a2df94133c6a2210b57e0c61beb74525e Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Sun, 25 Nov 2018 17:51:57 +0100 Subject: [PATCH] use multi-stage build for Docker images, decreasing the size by >80% --- Dockerfile.magneticod | 12 ++++++------ Dockerfile.magneticow | 7 +++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Dockerfile.magneticod b/Dockerfile.magneticod index 6d60a65..4c3361a 100644 --- a/Dockerfile.magneticod +++ b/Dockerfile.magneticod @@ -2,7 +2,7 @@ # Start from a Debian image with the latest version of Go installed # and a workspace (GOPATH) configured at /go. -FROM golang:1.10 +FROM golang:1.10 AS build # Copy the local package files to the container's workspace. ADD ./Gopkg.toml /go/src/github.com/boramalper/magnetico/ @@ -20,9 +20,9 @@ RUN make test-persistence RUN make test-magneticod RUN make magneticod -# Run the outyet command by default when the container starts. -ENTRYPOINT ["/go/bin/magneticod"] -CMD [] +FROM alpine:latest +WORKDIR / +COPY --from=build /go/bin/magneticod /magneticod -# Document that the service listens on port 8080. -EXPOSE 8080 +# Run the outyet command by default when the container starts. +ENTRYPOINT ["/magneticod"] diff --git a/Dockerfile.magneticow b/Dockerfile.magneticow index dbea944..6f0ce23 100644 --- a/Dockerfile.magneticow +++ b/Dockerfile.magneticow @@ -20,9 +20,12 @@ RUN make test-persistence RUN make test-magneticow RUN make magneticow +FROM alpine:latest +WORKDIR / +COPY --from=build /go/bin/magneticow /magneticow + # Run the outyet command by default when the container starts. -ENTRYPOINT ["/go/bin/magneticow"] -CMD [] +ENTRYPOINT ["/magneticow"] # Document that the service listens on port 8080. EXPOSE 8080