From 9c830be1009440c42400b4e8a9dcd8952486814f Mon Sep 17 00:00:00 2001 From: Marc Deop Date: Wed, 30 Sep 2020 16:49:03 +0200 Subject: [PATCH] feat: use multistage build to minimize container size --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8bd1a15..db3126e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,23 +2,23 @@ # MailHog Dockerfile # -FROM golang:alpine +FROM golang:alpine as builder # Install MailHog: RUN apk --no-cache add --virtual build-dependencies \ git \ && mkdir -p /root/gocode \ && export GOPATH=/root/gocode \ - && go get github.com/mailhog/MailHog \ - && mv /root/gocode/bin/MailHog /usr/local/bin \ - && rm -rf /root/gocode \ - && apk del --purge build-dependencies + && go get github.com/mailhog/MailHog +FROM alpine:3 # Add mailhog user/group with uid/gid 1000. # This is a workaround for boot2docker issue #581, see # https://github.com/boot2docker/boot2docker/issues/581 RUN adduser -D -u 1000 mailhog +COPY --from=builder /root/gocode/bin/MailHog /usr/local/bin/ + USER mailhog WORKDIR /home/mailhog