Skip to content

Commit 964dc4c

Browse files
authored
Merge pull request #1575 from srm09/automated-cherry-pick-of-#1574-upstream-release-1.3
Automated cherry pick of #1574: Adds go mod download directive to Dockerfile
2 parents 177c0bb + 7291193 commit 964dc4c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Dockerfile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,23 @@ WORKDIR /workspace
2323
ARG goproxy=https://proxy.golang.org
2424
ENV GOPROXY=${goproxy}
2525

26+
# Copy the Go Modules manifests
27+
COPY go.mod go.mod
28+
COPY go.sum go.sum
29+
30+
# Cache deps before building and copying source so that we don't need to re-download as much
31+
# and so that source changes don't invalidate our downloaded layer
32+
RUN --mount=type=cache,target=/go/pkg/mod \
33+
go mod download
34+
2635
# Build
2736
ARG TARGETOS
2837
ARG TARGETARCH
2938
ARG ldflags
3039
RUN --mount=type=bind,target=. \
3140
--mount=type=cache,target=/root/.cache/go-build \
32-
--mount=type=cache,target=/go/pkg \
33-
CGO_ENABLED=0 GOOS=linux GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
41+
--mount=type=cache,target=/go/pkg/mod \
42+
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
3443
go build -a -ldflags "${ldflags} -extldflags '-static'" \
3544
-o /out/manager .
3645

0 commit comments

Comments
 (0)