From c33fdac7be238bae7aaab728fef505e34ac13cbc Mon Sep 17 00:00:00 2001 From: Souyama Date: Mon, 25 Dec 2023 17:09:27 +0000 Subject: [PATCH 1/2] Improve build time with build caches Signed-off-by: Souyama --- Dockerfile | 6 +++++- Dockerfile.adapter | 6 +++++- Dockerfile.webhooks | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 11c8e58f912..d1cdf69f522 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,11 @@ COPY go.sum go.sum # https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/ ARG TARGETOS ARG TARGETARCH -RUN VERSION=${BUILD_VERSION} GIT_COMMIT=${GIT_COMMIT} GIT_VERSION=${GIT_VERSION} TARGET_OS=$TARGETOS ARCH=$TARGETARCH make manager +ARG GOCACHE=/root/.cache/go-build +RUN go env -w GOCACHE=${GOCACHE} +RUN --mount=type=cache,target=${GOCACHE} \ + VERSION=${BUILD_VERSION} GIT_COMMIT=${GIT_COMMIT} GIT_VERSION=${GIT_VERSION} TARGET_OS=$TARGETOS ARCH=$TARGETARCH \ + make manager # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/Dockerfile.adapter b/Dockerfile.adapter index 10ebae4f18e..05fe3c6de3e 100644 --- a/Dockerfile.adapter +++ b/Dockerfile.adapter @@ -24,7 +24,11 @@ COPY go.sum go.sum # https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/ ARG TARGETOS ARG TARGETARCH -RUN VERSION=${BUILD_VERSION} GIT_COMMIT=${GIT_COMMIT} GIT_VERSION=${GIT_VERSION} TARGET_OS=$TARGETOS ARCH=$TARGETARCH make adapter +ARG GOCACHE=/root/.cache/go-build +RUN go env -w GOCACHE=${GOCACHE} +RUN --mount=type=cache,target=${GOCACHE} \ + VERSION=${BUILD_VERSION} GIT_COMMIT=${GIT_COMMIT} GIT_VERSION=${GIT_VERSION} TARGET_OS=$TARGETOS ARCH=$TARGETARCH \ + make adapter # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/Dockerfile.webhooks b/Dockerfile.webhooks index b9115c81b48..a982075b033 100644 --- a/Dockerfile.webhooks +++ b/Dockerfile.webhooks @@ -24,7 +24,11 @@ COPY go.sum go.sum # https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/ ARG TARGETOS ARG TARGETARCH -RUN VERSION=${BUILD_VERSION} GIT_COMMIT=${GIT_COMMIT} GIT_VERSION=${GIT_VERSION} TARGET_OS=$TARGETOS ARCH=$TARGETARCH make webhooks +ARG GOCACHE=/root/.cache/go-build +RUN go env -w GOCACHE=${GOCACHE} +RUN --mount=type=cache,target=${GOCACHE} \ + VERSION=${BUILD_VERSION} GIT_COMMIT=${GIT_COMMIT} GIT_VERSION=${GIT_VERSION} TARGET_OS=$TARGETOS ARCH=$TARGETARCH \ + make webhooks # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details From 0e8ce7dac4c154b4b4300144014a8e76d55fe1a3 Mon Sep 17 00:00:00 2001 From: Souyama Date: Tue, 26 Dec 2023 15:17:17 +0000 Subject: [PATCH 2/2] Add to Changelog Signed-off-by: Souyama --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9930992301d..96a21d0590a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -111,6 +111,7 @@ New deprecation(s): - **General**: Fix CVE-2023-45142 in Opentelemetry ([#5089](https://github.com/kedacore/keda/issues/5089)) - **General**: Fix logger in Opentelemetry collector ([#5094](https://github.com/kedacore/keda/issues/5094)) - **General**: Fix lost commit from the newly created utility function ([#5037](https://github.com/kedacore/keda/issues/5037)) +- **General**: Improve docker image build time through caches ([#5316](https://github.com/kedacore/keda/issues/5316)) - **General**: Reduce amount of gauge creations for OpenTelemetry metrics ([#5101](https://github.com/kedacore/keda/issues/5101)) - **General**: Removed not required RBAC permissions ([#5261](https://github.com/kedacore/keda/issues/5261)) - **General**: Support profiling for KEDA components ([#4789](https://github.com/kedacore/keda/issues/4789))