From 874a9bcd3c861e8e4b95ad2fa5edf6271127d6dd Mon Sep 17 00:00:00 2001 From: David Laubreiter Date: Thu, 6 Feb 2025 15:34:34 +0100 Subject: [PATCH] ci: Allow to overwrite the ko base image path This allows us to use a different proxy instead of querying docker directly, potentially breaking the pipeline because of "You have reached your pull rate limit". By default, it still pulls from docker hub --- .ci/jenkins/tools/ko.groovy | 13 ++++++++----- Makefile | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.ci/jenkins/tools/ko.groovy b/.ci/jenkins/tools/ko.groovy index 83be03f58..e2135271a 100644 --- a/.ci/jenkins/tools/ko.groovy +++ b/.ci/jenkins/tools/ko.groovy @@ -28,10 +28,13 @@ private def registrySecret(String registry) { return [[path : "${path}", secretValues: [ - [envVar: 'registry', vaultKey: 'registry', isRequired: true], - [envVar: 'repo', vaultKey: 'repo', isRequired: true], - [envVar: 'username', vaultKey: 'username', isRequired: true], - [envVar: 'password', vaultKey: 'password', isRequired: true]]]] + [envVar: 'registry', vaultKey: 'registry', isRequired: true], + [envVar: 'repo', vaultKey: 'repo', isRequired: true], + [envVar: 'username', vaultKey: 'username', isRequired: true], + [envVar: 'password', vaultKey: 'password', isRequired: true] + [envVar: 'base_image_path', vaultKey: 'base_image_path', isRequired: true] + ] + ]] } @@ -49,7 +52,7 @@ String buildContainer(Map args = [tags: null, registry: null]) { withEnv(["tags=${args.tags.join(",")}", "version=${args.tags[0]}"]) { //, "vaultPath=${args.registrySecretsPath}" withVault(vaultSecrets: registrySecret(args.registry)) { sh(label: "build and publish container", - script: 'make docker-container REPO_PATH=$registry/$repo VERSION=$version TAGS=$tags') + script: 'make docker-container REPO_PATH=$registry/$repo VERSION=$version TAGS=$tags KO_BASE_IMAGE_PATH=$base_image_path' ) return "$registry/$repo/dynatrace-configuration-as-code:$version" } } diff --git a/Makefile b/Makefile index 8e7762622..50a35e51c 100644 --- a/Makefile +++ b/Makefile @@ -128,7 +128,8 @@ TAGS ?= $(VERSION) CONTAINER_NAME ?= dynatrace-configuration-as-code REPO_PATH ?= ko.local IMAGE_PATH ?= $(REPO_PATH)/$(CONTAINER_NAME) +KO_BASE_IMAGE_PATH ?= docker.io/library .PHONY: docker-container docker-container: install-ko @echo Building docker container... - KO_DOCKER_REPO=$(IMAGE_PATH) VERSION=$(VERSION) ko build --bare --sbom=none --tags=$(TAGS) ./cmd/monaco + KO_DOCKER_REPO=$(IMAGE_PATH) VERSION=$(VERSION) KO_DEFAULTBASEIMAGE=$(KO_BASE_IMAGE_PATH)/alpine:3.20 ko build --bare --sbom=none --tags=$(TAGS) ./cmd/monaco