From e97c0d109219611b7e7b8569aa6397b7f3942efd Mon Sep 17 00:00:00 2001 From: Rafael Soares Date: Wed, 27 Oct 2021 16:25:01 -0300 Subject: [PATCH] update Dockerfile to use multi-stage build --- docker/Dockerfile | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index d9a0012bf..f2ee77121 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,20 +1,19 @@ -FROM golang:1.16.6-alpine3.14 +FROM golang:1.16.8-bullseye AS builder -WORKDIR /app +WORKDIR /src + +COPY go.mod go.sum ./ +RUN go mod download -x -RUN apk update \ - && apk add --virtual build-deps gcc git \ - && rm -rf /var/cache/apk/* +COPY . ./ -RUN addgroup -S golang \ - && adduser -S -G golang golang +RUN GOOS=linux GOARCH=amd64 go build -o /bin/courier ./cmd/courier/*.go -COPY . . +FROM gcr.io/distroless/base-debian11 -RUN go install -v ./cmd/... -RUN chown -R golang /app +WORKDIR /app -USER golang +COPY --from=builder bin/courier ./ EXPOSE 8080 -ENTRYPOINT ["courier"] +ENTRYPOINT ["./courier"] \ No newline at end of file