Skip to content

Commit

Permalink
update Dockerfile to use multi-stage build
Browse files Browse the repository at this point in the history
  • Loading branch information
rasoro committed Oct 27, 2021
1 parent 8d70f22 commit e97c0d1
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions docker/Dockerfile
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"]

0 comments on commit e97c0d1

Please sign in to comment.