From d6558c3d4403f17b1e83a59bb75e877c99cdd2a3 Mon Sep 17 00:00:00 2001 From: Vitaliy Chefanov Date: Wed, 23 Sep 2026 21:27:31 +0300 Subject: [PATCH] Makefile: build into a local registry, publish only final artifacts werf keeps every stage in --repo, base images included; pushing Deckhouse's builder/golang-alpine (762 MB layer) to Gitea over a home uplink timed out. Stages now live in a local registry:2 and publish crane-copies the app image, bundle and release, keeping digests. Co-Authored-By: Claude Opus 5.5 --- Makefile | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 530ca49..bf1549b 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,18 @@ SOURCE ?= git.project-chimera.ru/fanchji/cluster-map CHANNEL ?= alpha BASE_IMAGES_VERSION ?= v2.1.7 CRANE ?= crane +WERF ?= werf +# Stages are built into a local registry and only the final artifacts are +# copied to SOURCE. werf keeps every stage in --repo, base images included +# (Deckhouse's builder/golang-alpine has a 762 MB layer), which a remote or +# small registry doesn't need to hold. crane copy keeps digests, so the +# images_digests.json baked into the bundle stays valid. +BUILD_REGISTRY ?= localhost:5555 +BUILD_REPO ?= $(BUILD_REGISTRY)/$(MODULE) DMT ?= dmt API_VERSIONS ?= --api-versions autoscaling.k8s.io/v1/VerticalPodAutoscaler --api-versions monitoring.coreos.com/v1/PodMonitor -.PHONY: test lint render base-images build publish release +.PHONY: test lint render base-images build-registry build publish release test: cd images/cluster-map/src && go test -race -count=1 ./... @@ -49,13 +57,22 @@ base_images.yml: base-images: base_images.yml -build: base_images.yml - @test -n "$(VERSION)" || (echo "VERSION is required, e.g. VERSION=v0.7.0" && exit 1) - MODULES_MODULE_TAG=$(VERSION) werf build --repo=$(SOURCE)/$(MODULE) --save-build-report --build-report-path images_tags_werf.json +build-registry: + @docker inspect cluster-map-build-registry >/dev/null 2>&1 || \ + docker run -d --name cluster-map-build-registry -p 127.0.0.1:5555:5000 -v cluster-map-build-registry:/var/lib/registry registry:2 >/dev/null + @until curl -sf http://$(BUILD_REGISTRY)/v2/ >/dev/null; do sleep 1; done +build: base_images.yml build-registry + @test -n "$(VERSION)" || (echo "VERSION is required, e.g. VERSION=v0.7.0" && exit 1) + MODULES_MODULE_TAG=$(VERSION) $(WERF) build --repo=$(BUILD_REPO) --insecure-registry --save-build-report --build-report-path images_tags_werf.json + +# Application images first (the bundle refers to them by digest), then the +# bundle and the release, then the module registration. publish: build - $(CRANE) copy "$$(jq -r '.Images.bundle.DockerImageName' images_tags_werf.json)" "$(SOURCE)/$(MODULE):$(VERSION)" - $(CRANE) copy "$$(jq -r '.Images."release-channel-version".DockerImageName' images_tags_werf.json)" "$(SOURCE)/$(MODULE)/release:$(VERSION)" + jq -r '.Images | to_entries[] | select((.key | startswith("$(MODULE)/")) and (.key | endswith("-build") | not)) | .value.DockerImageName' images_tags_werf.json \ + | while read -r img; do $(CRANE) copy --insecure "$$img" "$(SOURCE)/$(MODULE):$${img##*:}"; done + $(CRANE) copy --insecure "$$(jq -r '.Images.bundle.DockerImageName' images_tags_werf.json)" "$(SOURCE)/$(MODULE):$(VERSION)" + $(CRANE) copy --insecure "$$(jq -r '.Images."release-channel-version".DockerImageName' images_tags_werf.json)" "$(SOURCE)/$(MODULE)/release:$(VERSION)" $(CRANE) append --oci-empty-base --new_layer "" --new_tag "$(SOURCE):$(MODULE)" $(MAKE) release VERSION=$(VERSION) CHANNEL=$(CHANNEL)