Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile: cache go modules on build #1798

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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