From ac2b7d70d43ee9a896808ea0f33dc7b1a9cc21e2 Mon Sep 17 00:00:00 2001 From: Charles-Andre Flamand Date: Tue, 26 Mar 2024 12:50:36 -0400 Subject: [PATCH] Setup multistage Dockerfile --- Dockerfile | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index b127836..20a681b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,15 @@ -FROM golang:alpine3.19 +# Stage 1: Build the application +FROM golang:alpine3.19 AS builder -RUN apk add --no-cache \ - git - -RUN git clone \ - --depth 1 \ - --branch "v0.16.0" \ - https://github.com/honeycombio/buildevents /opt/buildevents \ +RUN apk add --no-cache git \ + && git clone --depth 1 --branch "v0.16.0" https://github.com/honeycombio/buildevents /opt/buildevents \ && cd /opt/buildevents \ - && go install github.com/honeycombio/buildevents/ + && go install github.com/honeycombio/buildevents/ \ + && apk del git + +# Stage 2: Create the final Docker image +FROM alpine:3.19 -RUN apk del \ - git +COPY --from=builder /go/bin/buildevents /usr/local/bin/buildevents ENTRYPOINT ["buildevents"]