Skip to content

Commit 51f2794

Browse files
authored
Merge pull request #1798 from marquiz/devel/docker-cache
Dockerfile: cache go modules on build
2 parents 1230d60 + 2f52f35 commit 51f2794

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ COPY api/nfd/go.mod api/nfd/go.sum /go/node-feature-discovery/api/nfd/
1111

1212
WORKDIR /go/node-feature-discovery
1313

14-
RUN go mod download
14+
RUN --mount=type=cache,target=/go/pkg/mod/ \
15+
go mod download
1516

1617
# Do actual build
1718
COPY . /go/node-feature-discovery
1819

1920
ARG VERSION
2021
ARG HOSTMOUNT_PREFIX
2122

22-
RUN make install VERSION=$VERSION HOSTMOUNT_PREFIX=$HOSTMOUNT_PREFIX
23+
RUN --mount=type=cache,target=/go/pkg/mod/ \
24+
make install VERSION=$VERSION HOSTMOUNT_PREFIX=$HOSTMOUNT_PREFIX
2325

2426
# Create full variant of the production image
2527
FROM ${BASE_IMAGE_FULL} AS full

Dockerfile_generator

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ ARG BUILDER_IMAGE
22
FROM ${BUILDER_IMAGE} as builder
33

44
# Install tools
5-
RUN go install github.com/vektra/mockery/v2@v2.42.0 && \
5+
RUN --mount=type=cache,target=/go/pkg/mod/ \
6+
go install github.com/vektra/mockery/v2@v2.42.0 && \
67
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0 && \
78
go install golang.org/x/tools/cmd/goimports@v0.11.0 && \
89
go install github.com/golang/protobuf/protoc-gen-go@v1.4.3

0 commit comments

Comments
 (0)