Skip to content

Instantly share code, notes, and snippets.

@dln
Created March 30, 2021 07:57
Show Gist options
  • Save dln/899542a4ed49c868b6c91326e53e149a to your computer and use it in GitHub Desktop.
Save dln/899542a4ed49c868b6c91326e53e149a to your computer and use it in GitHub Desktop.
Multi-stage Dockerfile with multiple targets for gooder life
FROM golang:1.16-buster AS builder
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build ./cmd/director && \
go build ./cmd/frontend && \
go build ./cmd/matchfunction
FROM gcr.io/distroless/base-debian10 AS director
COPY --from=builder /src/director /
ENTRYPOINT ["/director"]
FROM gcr.io/distroless/base-debian10 AS frontend
COPY --from=builder /src/frontend /
ENTRYPOINT ["/frontend"]
FROM gcr.io/distroless/base-debian10 AS matchfunction
COPY --from=builder /src/matchfunction /
ENTRYPOINT ["/matchfunction"]
FROM builder AS test
RUN go test -v ./...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment