From 3251b428f19ebe9950fe3c6d4167fde6e9459ceb Mon Sep 17 00:00:00 2001 From: Connor Catlett Date: Tue, 2 Jul 2024 20:35:24 +0000 Subject: [PATCH] Cache GOCACHE and GOMODCACHE in Dockerfile Signed-off-by: Connor Catlett --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index f080a59848..8b486b6df0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,14 +17,15 @@ # for info on BUILDPLATFORM, TARGETOS, TARGETARCH, etc. FROM --platform=$BUILDPLATFORM golang:1.22 AS builder WORKDIR /go/src/github.com/kubernetes-sigs/aws-ebs-csi-driver +RUN go env -w GOCACHE=/gocache GOMODCACHE=/gomodcache COPY go.* . ARG GOPROXY -RUN go mod download +RUN --mount=type=cache,target=/gomodcache go mod download COPY . . ARG TARGETOS ARG TARGETARCH ARG VERSION -RUN OS=$TARGETOS ARCH=$TARGETARCH make +RUN --mount=type=cache,target=/gomodcache --mount=type=cache,target=/gocache OS=$TARGETOS ARCH=$TARGETARCH make FROM public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-csi-ebs:latest-al23 AS linux-al2023 COPY --from=builder /go/src/github.com/kubernetes-sigs/aws-ebs-csi-driver/bin/aws-ebs-csi-driver /bin/aws-ebs-csi-driver