1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

Dockerfile: cache go modules on build

This commit is contained in:
Markus Lehtonen 2024-07-18 15:58:16 +03:00
parent 1230d607ac
commit 2f52f35720
2 changed files with 6 additions and 3 deletions

View file

@ -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

View file

@ -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