chore: add Docker go mod and build cache (#25855)

This commit is contained in:
Blaž Dular 2025-12-07 13:42:11 +01:00 • committed by GitHub
parent b2f0bab074
commit 0bd636ea23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -32,10 +32,14 @@ ARG RELEASE=0
WORKDIR /build
# Setup Go cache
ENV GOCACHE=/root/.cache/go-build
ENV GOMODCACHE=/root/.cache/go-mod
# download modules
COPY go.mod .
COPY go.sum .
RUN go mod download
RUN --mount=type=cache,target="/root/.cache/go-mod" go mod download
# install tools
COPY Makefile .
@ -58,7 +62,8 @@ ARG TARGETARCH
ARG TARGETVARIANT
ARG GOARM=${TARGETVARIANT#v}
RUN RELEASE=${RELEASE} GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${GOARM} make build
RUN --mount=type=cache,target="/root/.cache/go-build" --mount=type=cache,target="/root/.cache/go-mod"\
RELEASE=${RELEASE} GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${GOARM} make build
# STEP 3 build a small image including module support