From 6fca76127561a749ba76bd99c78853d193cf23af Mon Sep 17 00:00:00 2001 From: Eric Wollesen Date: Mon, 12 Aug 2024 10:40:29 -0600 Subject: [PATCH] enable copying vendor and using go build cache in Dockerfile The docker ignore was ignoring vendor, and as a result, having to download a lot of packages on each build. By letting those be copied over locally, we can save a lot of extra downloading. Plus the build cache being saved between runs saves time as well. --- .dockerignore | 1 - Dockerfile | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.dockerignore b/.dockerignore index 4fd689e5e..1ebfa5976 100644 --- a/.dockerignore +++ b/.dockerignore @@ -18,5 +18,4 @@ /test.sh /tmp/ /tools/ -/vendor/ /version.sh diff --git a/Dockerfile b/Dockerfile index 7c6a63f78..57be23396 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,9 +7,9 @@ RUN apk --no-cache update && \ adduser -D tidepool && \ chown -R tidepool /go/src/github.com/tidepool-org/clinic USER tidepool -RUN go install github.com/air-verse/air@v1.52.2 +RUN --mount=type=cache,target=$HOME/.cache/go-build go install github.com/air-verse/air@v1.52.2 COPY --chown=tidepool . . -RUN ./build.sh +RUN --mount=type=cache,target=$HOME/.cache/go-build ./build.sh CMD ["air"] # Production @@ -22,7 +22,7 @@ RUN apk --no-cache update && \ chown -R tidepool /go/src/github.com/tidepool-org/clinic USER tidepool COPY --chown=tidepool . . -RUN ./build.sh +RUN --mount=type=cache,target=$HOME/.cache/go-build ./build.sh WORKDIR /go/src/github.com/tidepool-org/clinic/dist CMD ["./clinic"]