From cb837575661644db66880b41c2e85f6e2a74ba8d Mon Sep 17 00:00:00 2001 From: StealWonders <6114858+StealWonders@users.noreply.github.com> Date: Mon, 4 Mar 2024 12:27:21 +0100 Subject: [PATCH] adds better cache behavior --- Dockerfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c9b3c14..e6c8468 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ FROM golang:1.22-alpine as base +# Install git for VCS build information +RUN apk add --no-cache git + # Create another stage called "dev" that is based off of our "base" stage (so we have golang available to us) FROM base as dev @@ -15,9 +18,13 @@ CMD ["air"] FROM base as built WORKDIR /go/app/mensatt -COPY . . +# Install required dependencies here for better cache utilization +COPY go.mod go.sum ./ RUN go mod download + +# Copy the rest of the code and build the binary +COPY . . RUN go build -o /tmp/mensatt ./cmd/mensatt/main.go FROM alpine:3.19 as prod