diff --git a/Dockerfile b/Dockerfile index 6bbbf81c2..b6bb7b30f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,8 @@ COPY api/nfd/go.mod api/nfd/go.sum /go/node-feature-discovery/api/nfd/ WORKDIR /go/node-feature-discovery -RUN go mod download +RUN --mount=type=cache,target=/go/pkg/mod/ \ + go mod download # Do actual build COPY . /go/node-feature-discovery @@ -19,7 +20,8 @@ COPY . /go/node-feature-discovery ARG VERSION ARG HOSTMOUNT_PREFIX -RUN make install VERSION=$VERSION HOSTMOUNT_PREFIX=$HOSTMOUNT_PREFIX +RUN --mount=type=cache,target=/go/pkg/mod/ \ + make install VERSION=$VERSION HOSTMOUNT_PREFIX=$HOSTMOUNT_PREFIX # Create full variant of the production image FROM ${BASE_IMAGE_FULL} AS full diff --git a/Dockerfile_generator b/Dockerfile_generator index a41ebbd9a..c558c2d78 100644 --- a/Dockerfile_generator +++ b/Dockerfile_generator @@ -2,7 +2,8 @@ ARG BUILDER_IMAGE FROM ${BUILDER_IMAGE} as builder # Install tools -RUN go install github.com/vektra/mockery/v2@v2.42.0 && \ +RUN --mount=type=cache,target=/go/pkg/mod/ \ + go install github.com/vektra/mockery/v2@v2.42.0 && \ go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0 && \ go install golang.org/x/tools/cmd/goimports@v0.11.0 && \ go install github.com/golang/protobuf/protoc-gen-go@v1.4.3