From 4e39a436da6aaf6dd4dc9dda0e91a2c9fa19fc3b Mon Sep 17 00:00:00 2001 From: Ruslan Aliev Date: Thu, 16 Dec 2021 01:50:24 +0000 Subject: [PATCH] Speed-up building applier and clusterctl images Use caching to download go modules. Change-Id: I9fa7d19f9daaa73675dfb8c59ffed0ad08638631 Signed-off-by: Ruslan Aliev --- krm-functions/applier/Dockerfile | 3 ++- krm-functions/clusterctl/Dockerfile | 3 ++- krm-functions/kubeval-validator/Dockerfile | 5 ++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/krm-functions/applier/Dockerfile b/krm-functions/applier/Dockerfile index 074e1cde8..c4901ee8d 100644 --- a/krm-functions/applier/Dockerfile +++ b/krm-functions/applier/Dockerfile @@ -12,8 +12,9 @@ RUN update-ca-certificates ENV PATH "/usr/local/go/bin:$PATH" ENV CGO_ENABLED=0 WORKDIR /go/src/ -COPY image/ . +COPY image/go.mod image/go.sum ./ RUN go mod download +COPY image/ ./ RUN go build -v -o /usr/local/bin/config-function ./ FROM ${PLUGINS_RELEASE_IMAGE} as release diff --git a/krm-functions/clusterctl/Dockerfile b/krm-functions/clusterctl/Dockerfile index 35e9585e9..d000bc022 100644 --- a/krm-functions/clusterctl/Dockerfile +++ b/krm-functions/clusterctl/Dockerfile @@ -24,8 +24,9 @@ RUN update-ca-certificates ENV PATH "/usr/local/go/bin:$PATH" ENV CGO_ENABLED=0 WORKDIR /go/src/ -COPY image/ . +COPY image/go.mod image/go.sum ./ RUN go mod download +COPY image/ ./ RUN go build -v -o /usr/local/bin/config-function ./ FROM ${PLUGINS_RELEASE_IMAGE} as release diff --git a/krm-functions/kubeval-validator/Dockerfile b/krm-functions/kubeval-validator/Dockerfile index 7504a85c9..7f058eefe 100644 --- a/krm-functions/kubeval-validator/Dockerfile +++ b/krm-functions/kubeval-validator/Dockerfile @@ -12,10 +12,9 @@ RUN update-ca-certificates ENV PATH "/usr/local/go/bin:$PATH" ENV CGO_ENABLED=0 WORKDIR /go/src/ -COPY image/go.mod . -COPY image/go.sum . +COPY image/go.mod image/go.sum ./ RUN go mod download -COPY image/main.go . +COPY image/ ./ RUN go build -v -o /usr/local/bin/config-function ./ FROM ${PLUGINS_RELEASE_IMAGE} as release