File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -23,14 +23,23 @@ WORKDIR /workspace
2323ARG goproxy=https://proxy.golang.org
2424ENV 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
2736ARG TARGETOS
2837ARG TARGETARCH
2938ARG ldflags
3039RUN --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
You can’t perform that action at this time.
0 commit comments