From fc8957a5828c51b93ef0f700ed6f40a6b97c4c4d Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 14 May 2020 17:42:04 +0300 Subject: [PATCH] Dockerfile: fetch build dependencies in a separate layer Effectively caches them, making subsequent builds much faster (assuming go.mod and go.sum) are not changed). --- Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e453428e..1c27df70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,13 @@ # Build the operator FROM registry.access.redhat.com/ubi8/go-toolset AS builder WORKDIR /go/src/github.com/kubernetes-sigs/node-feature-discovery-operator -COPY . . + +# Fetch/cache dependencies +COPY go.mod go.sum ./ +RUN go mod download # do the actual build +COPY . . RUN make build # Create production image for running the operator