Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update Dockerfile to use multi-stage build #53

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]