Skip to content

Commit

Permalink
Merge pull request #1798 from marquiz/devel/docker-cache
Browse files Browse the repository at this point in the history
Dockerfile: cache go modules on build
  • Loading branch information
k8s-ci-robot authored Jul 18, 2024
2 parents 1230d60 + 2f52f35 commit 51f2794
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ 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

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
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile_generator
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ ARG BUILDER_IMAGE
FROM ${BUILDER_IMAGE} as builder

# Install tools
RUN go install github.com/vektra/mockery/[email protected] && \
RUN --mount=type=cache,target=/go/pkg/mod/ \
go install github.com/vektra/mockery/[email protected] && \
go install sigs.k8s.io/controller-tools/cmd/[email protected] && \
go install golang.org/x/tools/cmd/[email protected] && \
go install github.com/golang/protobuf/[email protected]
Expand Down

0 comments on commit 51f2794

Please sign in to comment.