From db186dddfa772590387921490fa6aad802b9f21f Mon Sep 17 00:00:00 2001 From: Rafael Soares Date: Wed, 27 Oct 2021 16:24:52 -0300 Subject: [PATCH] update Dockerfile to use multi-stage build --- docker/Dockerfile | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index c9feda2bd..dbbef1990 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,21 +1,22 @@ -FROM golang:1.16.6-alpine3.14 +FROM golang:1.16.8-bullseye AS builder -WORKDIR /app - -RUN apk update \ - && apk add --virtual build-deps gcc git curl tar \ - && rm -rf /var/cache/apk/* +WORKDIR /src -RUN addgroup -S golang \ - && adduser -S -G golang golang +COPY go.mod go.sum ./ +RUN go mod download -x -COPY . . +COPY . ./ RUN curl -L https://github.com/nyaruka/goflow/releases/download/v$(grep goflow go.mod | cut -d" " -f2 | cut -c2-)/docs.tar.gz --output docs.tar.gz && \ tar -xf docs.tar.gz && rm docs.tar.gz +RUN GOOS=linux GOARCH=amd64 go build -o /bin/mailroom ./cmd/mailroom/*.go + +FROM gcr.io/distroless/base-debian11 + +WORKDIR /app -RUN go install -v ./cmd/... +COPY --from=builder bin/mailroom ./ -EXPOSE 8000 -ENTRYPOINT ["mailroom"] +EXPOSE 8090 +ENTRYPOINT ["./mailroom"] \ No newline at end of file