forked from nyaruka/courier
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update Dockerfile to use multi-stage build
- Loading branch information
Showing
1 changed file
with
11 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] |