Created
March 30, 2021 07:57
-
-
Save dln/899542a4ed49c868b6c91326e53e149a to your computer and use it in GitHub Desktop.
Multi-stage Dockerfile with multiple targets for gooder life
This file contains hidden or 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
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