Files
cozystack/packages/system/dashboard/Makefile
Myasnikov Daniil a576f33461 refactor(build): mode=max registry cache with a main-only warmer
`--cache-to type=inline` only exports the final stage. 25 of 38 Dockerfiles are multistage, so the expensive `builder` stages (Go/Node compiles) were never cached even with a warm tag. Switch every image to a shared mode=max registry cache.

- New `cache-args` macro (hack/common-envs.mk) emits `--cache-from` always and `--cache-to … mode=max` only when WRITE_CACHE=1, so PR builds stay read-only and concurrent PRs never race on the cache ref (the 409 class #2711 fixed for tags). oci-mediatypes/image-manifest keep the cache manifest portable across registries.

- Cache ref is CACHE_REGISTRY/<img>:buildcache, co-located with the build registry (CACHE_REGISTRY now defaults to $(REGISTRY)).

- New build-main.yaml warms :buildcache on every push to main (WRITE_CACHE=1), serialized via concurrency.

All 31 package image recipes converted from the inline cache-from/cache-to pair to `$(call cache-args,…)`; ubuntu-container-disk keeps a per-k8s-version cache tag. Verified with `make -n image` across all packages in both PR (read-only) and main (mode=max write) contexts.

Part of #2937.

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-06-17 20:50:01 +05:00

65 lines
2.0 KiB
Makefile

export NAME=dashboard
export NAMESPACE=cozy-$(NAME)
include ../../../hack/common-envs.mk
include ../../../hack/package.mk
.PHONY: image image-console image-token-proxy test test-go test-helm
.PHONY: clone-console build-console update-values-console clean-console
.NOTPARALLEL: image
test: test-helm test-go
test-helm:
helm unittest .
test-go:
cd images/token-proxy && go test ./...
image: image-console image-token-proxy
CONSOLE_REPO ?= https://github.com/cozystack/cozystack-ui.git
CONSOLE_BRANCH ?= main
image-console: clone-console build-console update-values-console clean-console
clone-console:
rm -rf .tmp-cozystack-ui
git clone --depth 1 --branch $(CONSOLE_BRANCH) $(CONSOLE_REPO) .tmp-cozystack-ui
build-console:
docker buildx build .tmp-cozystack-ui \
--file .tmp-cozystack-ui/Containerfile \
--provenance false \
--builder=$(BUILDER) \
--platform=linux/amd64 \
$(call image-tags,cozystack-ui,v$(COZYSTACK_VERSION)) \
$(call cache-args,cozystack-ui) \
--metadata-file images/console.json \
--build-arg APP_VERSION=$(COZYSTACK_VERSION) \
--push=$(PUSH) \
--label "org.opencontainers.image.source=https://github.com/cozystack/cozystack-ui" \
--load=$(LOAD)
update-values-console:
IMAGE="$(REGISTRY)/cozystack-ui:$(IMAGE_TAG)@$$(yq e '."containerimage.digest"' images/console.json -r)" \
yq -i '.console.image = strenv(IMAGE)' values.yaml
clean-console:
rm -rf .tmp-cozystack-ui images/console.json
image-token-proxy:
docker buildx build images/token-proxy \
--provenance false \
--builder=$(BUILDER) \
--platform=linux/amd64 \
$(call image-tags,token-proxy,v$(COZYSTACK_VERSION)) \
$(call cache-args,token-proxy) \
--metadata-file images/token-proxy.json \
--push=$(PUSH) \
--label "org.opencontainers.image.source=https://github.com/cozystack/cozystack" \
--load=$(LOAD)
IMAGE="$(REGISTRY)/token-proxy:$(IMAGE_TAG)@$$(yq e '."containerimage.digest"' images/token-proxy.json -r)" \
yq -i '.tokenProxy.image = strenv(IMAGE)' values.yaml
rm -f images/token-proxy.json