Files
cozystack/packages/core/installer/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

52 lines
1.9 KiB
Makefile

NAME=installer
NAMESPACE=cozy-system
include ../../../hack/common-envs.mk
pre-checks:
../../../hack/pre-checks.sh
show:
cozyhr show --namespace $(NAMESPACE) $(NAME) --plain
apply:
cozyhr show --namespace $(NAMESPACE) $(NAME) --plain | kubectl apply -f -
diff:
cozyhr show --namespace $(NAMESPACE) $(NAME) --plain | kubectl diff -f -
image: pre-checks image-operator image-packages chart
image-operator:
docker buildx build -f images/cozystack-operator/Dockerfile ../../.. \
$(call image-tags,cozystack-operator,v$(COZYSTACK_VERSION)) \
--build-arg VERSION=v$(COZYSTACK_VERSION) \
$(call cache-args,cozystack-operator) \
--metadata-file images/cozystack-operator.json \
$(BUILDX_ARGS)
IMAGE="$(REGISTRY)/cozystack-operator:$(IMAGE_TAG)@$$(yq -e '.["containerimage.digest"]' images/cozystack-operator.json -o json -r)" \
yq -i '.cozystackOperator.image = strenv(IMAGE)' values.yaml
rm -f images/cozystack-operator.json
image-packages:
mkdir -p ../../../_out/assets images
echo $$(git rev-parse HEAD; git diff HEAD; git ls-files --others --exclude-standard) | shasum -a 256 > ../platform/.build-revision
flux push artifact \
oci://$(REGISTRY)/cozystack-packages:$(IMAGE_TAG) \
--path=../../../packages \
--source=https://github.com/cozystack/cozystack \
--revision="$$(git describe --tags):$$(git rev-parse HEAD)" \
2>&1 | tee images/cozystack-packages.log
export REPO="oci://$(REGISTRY)/cozystack-packages" \
export DIGEST=$$(awk -F @ '/artifact successfully pushed/ {print $$2}' images/cozystack-packages.log) && \
rm -f images/cozystack-packages.log && \
test -n "$$DIGEST" && \
yq -i '.cozystackOperator.platformSourceUrl = strenv(REPO)' values.yaml && \
yq -i '.cozystackOperator.platformSourceRef = "digest=" + strenv(DIGEST)' values.yaml
chart:
set -e; \
PKG=$$(helm package . --version $(COZYSTACK_VERSION) | awk '{print $$NF}'); \
trap 'rm -f "$$PKG"' EXIT; \
if [ "$(PUSH)" = "1" ]; then helm push "$$PKG" oci://$(REGISTRY); fi