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 #79

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
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"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing endline here