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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
18869e8bfc
commit
d6558c3d44
@@ -18,10 +18,18 @@ SOURCE ?= git.project-chimera.ru/fanchji/cluster-map
|
|||||||
CHANNEL ?= alpha
|
CHANNEL ?= alpha
|
||||||
BASE_IMAGES_VERSION ?= v2.1.7
|
BASE_IMAGES_VERSION ?= v2.1.7
|
||||||
CRANE ?= crane
|
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
|
DMT ?= dmt
|
||||||
API_VERSIONS ?= --api-versions autoscaling.k8s.io/v1/VerticalPodAutoscaler --api-versions monitoring.coreos.com/v1/PodMonitor
|
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:
|
test:
|
||||||
cd images/cluster-map/src && go test -race -count=1 ./...
|
cd images/cluster-map/src && go test -race -count=1 ./...
|
||||||
@@ -49,13 +57,22 @@ base_images.yml:
|
|||||||
|
|
||||||
base-images: base_images.yml
|
base-images: base_images.yml
|
||||||
|
|
||||||
build: base_images.yml
|
build-registry:
|
||||||
@test -n "$(VERSION)" || (echo "VERSION is required, e.g. VERSION=v0.7.0" && exit 1)
|
@docker inspect cluster-map-build-registry >/dev/null 2>&1 || \
|
||||||
MODULES_MODULE_TAG=$(VERSION) werf build --repo=$(SOURCE)/$(MODULE) --save-build-report --build-report-path images_tags_werf.json
|
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
|
publish: build
|
||||||
$(CRANE) copy "$$(jq -r '.Images.bundle.DockerImageName' images_tags_werf.json)" "$(SOURCE)/$(MODULE):$(VERSION)"
|
jq -r '.Images | to_entries[] | select((.key | startswith("$(MODULE)/")) and (.key | endswith("-build") | not)) | .value.DockerImageName' images_tags_werf.json \
|
||||||
$(CRANE) copy "$$(jq -r '.Images."release-channel-version".DockerImageName' images_tags_werf.json)" "$(SOURCE)/$(MODULE)/release:$(VERSION)"
|
| 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)"
|
$(CRANE) append --oci-empty-base --new_layer "" --new_tag "$(SOURCE):$(MODULE)"
|
||||||
$(MAKE) release VERSION=$(VERSION) CHANNEL=$(CHANNEL)
|
$(MAKE) release VERSION=$(VERSION) CHANNEL=$(CHANNEL)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user