Skip to content

Commit 9868c43

Browse files
fix(build): read --cache-from from ghcr :latest so PR builds warm-start
PR #2711 switched PR builds to push only :pr-<N>-<sha> tags (PUBLISH_FLOATING=0) to stop concurrent-push 409 conflicts, but left --cache-from pointing at $(REGISTRY)/<img>:latest. PR builds set REGISTRY to the per-CI registry (iad.ocir.io) and never publish :latest there, so every PR build's registry cache lookup 404s and rebuilds cold. Add a CACHE_REGISTRY knob (default ghcr.io/cozystack/cozystack, where release builds do publish :latest) and point every --cache-from at it. Push targets ($(REGISTRY)) and the unique per-PR tags are unchanged, so the #2711 anti-conflict behaviour is preserved while PR builds regain a warm cache from the last release. Assisted-By: Claude <[email protected]> Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent 80fbfa1 commit 9868c43

32 files changed

Lines changed: 45 additions & 37 deletions

File tree

‎hack/common-envs.mk‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ endif
77

88
REGISTRY ?= ghcr.io/cozystack/cozystack
99

10+
# CACHE_REGISTRY: registry that `--cache-from` reads build cache from. It must
11+
# point at a registry where a `:latest` tag is actually published. PR builds
12+
# set REGISTRY to a per-CI registry and push only unique `pr-<N>-<sha>` tags
13+
# (PUBLISH_FLOATING=0), so they never refresh `:latest` there — reading cache
14+
# from $(REGISTRY):latest would always 404. Release builds publish `:latest`
15+
# to ghcr.io, so default cache reads there and stays warm across PR builds.
16+
CACHE_REGISTRY ?= ghcr.io/cozystack/cozystack
17+
1018
# IMAGE_TAG: build-unique tag pushed for every image. Set by CI to a value
1119
# that does not collide between concurrent builds:
1220
# * pull-requests.yaml -> pr-<N>-<sha>

‎packages/apps/clickhouse/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test:
1313
image:
1414
docker buildx build images/clickhouse-backup \
1515
$(call image-tags,clickhouse-backup,$(CLICKHOUSE_BACKUP_TAG)) \
16-
--cache-from type=registry,ref=$(REGISTRY)/clickhouse-backup:latest \
16+
--cache-from type=registry,ref=$(CACHE_REGISTRY)/clickhouse-backup:latest \
1717
--cache-to type=inline \
1818
--metadata-file images/clickhouse-backup.json \
1919
$(BUILDX_ARGS)
@@ -22,7 +22,7 @@ image:
2222
rm -f images/clickhouse-backup.json
2323
docker buildx build images/altinity-clickhouse-backup \
2424
$(call image-tags,altinity-clickhouse-backup,$(CLICKHOUSE_BACKUP_TAG)) \
25-
--cache-from type=registry,ref=$(REGISTRY)/altinity-clickhouse-backup:latest \
25+
--cache-from type=registry,ref=$(CACHE_REGISTRY)/altinity-clickhouse-backup:latest \
2626
--cache-to type=inline \
2727
--metadata-file images/altinity-clickhouse-backup.json \
2828
$(BUILDX_ARGS)

‎packages/apps/http-cache/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ image: image-nginx
88
image-nginx:
99
docker buildx build images/nginx-cache \
1010
$(call image-tags,nginx-cache,$(NGINX_CACHE_TAG)) \
11-
--cache-from type=registry,ref=$(REGISTRY)/nginx-cache:latest \
11+
--cache-from type=registry,ref=$(CACHE_REGISTRY)/nginx-cache:latest \
1212
--cache-to type=inline \
1313
--metadata-file images/nginx-cache.json \
1414
$(BUILDX_ARGS)

‎packages/apps/kubernetes/Makefile‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ image-ubuntu-container-disk:
2626
--build-arg KUBERNETES_VERSION=$(ver) \
2727
--tag $(REGISTRY)/ubuntu-container-disk:$(ver)-$(IMAGE_TAG) \
2828
$(if $(filter 1,$(PUBLISH_VERSIONED)),--tag $(REGISTRY)/ubuntu-container-disk:$(ver)) \
29-
--cache-from type=registry,ref=$(REGISTRY)/ubuntu-container-disk:$(ver) \
29+
--cache-from type=registry,ref=$(CACHE_REGISTRY)/ubuntu-container-disk:$(ver) \
3030
--cache-to type=inline \
3131
--metadata-file images/ubuntu-container-disk-$(ver).json \
3232
$(BUILDX_ARGS) && \
@@ -38,7 +38,7 @@ image-ubuntu-container-disk:
3838
image-kubevirt-cloud-provider:
3939
docker buildx build images/kubevirt-cloud-provider \
4040
$(call image-tags,kubevirt-cloud-provider,$(KUBERNETES_PKG_TAG)) \
41-
--cache-from type=registry,ref=$(REGISTRY)/kubevirt-cloud-provider:latest \
41+
--cache-from type=registry,ref=$(CACHE_REGISTRY)/kubevirt-cloud-provider:latest \
4242
--cache-to type=inline \
4343
--metadata-file images/kubevirt-cloud-provider.json \
4444
$(BUILDX_ARGS)
@@ -49,7 +49,7 @@ image-kubevirt-cloud-provider:
4949
image-kubevirt-csi-driver:
5050
docker buildx build images/kubevirt-csi-driver \
5151
$(call image-tags,kubevirt-csi-driver,$(KUBERNETES_PKG_TAG)) \
52-
--cache-from type=registry,ref=$(REGISTRY)/kubevirt-csi-driver:latest \
52+
--cache-from type=registry,ref=$(CACHE_REGISTRY)/kubevirt-csi-driver:latest \
5353
--cache-to type=inline \
5454
--metadata-file images/kubevirt-csi-driver.json \
5555
$(BUILDX_ARGS)
@@ -63,7 +63,7 @@ image-kubevirt-csi-driver:
6363
image-cluster-autoscaler:
6464
docker buildx build images/cluster-autoscaler \
6565
$(call image-tags,cluster-autoscaler,$(KUBERNETES_PKG_TAG)) \
66-
--cache-from type=registry,ref=$(REGISTRY)/cluster-autoscaler:latest \
66+
--cache-from type=registry,ref=$(CACHE_REGISTRY)/cluster-autoscaler:latest \
6767
--cache-to type=inline \
6868
--metadata-file images/cluster-autoscaler.json \
6969
$(BUILDX_ARGS)

‎packages/apps/mariadb/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ update:
1414
image:
1515
docker buildx build images/mariadb-backup \
1616
$(call image-tags,mariadb-backup,$(MARIADB_BACKUP_TAG)) \
17-
--cache-from type=registry,ref=$(REGISTRY)/mariadb-backup:latest \
17+
--cache-from type=registry,ref=$(CACHE_REGISTRY)/mariadb-backup:latest \
1818
--cache-to type=inline \
1919
--metadata-file images/mariadb-backup.json \
2020
$(BUILDX_ARGS)

‎packages/core/installer/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ image-operator:
2121
docker buildx build -f images/cozystack-operator/Dockerfile ../../.. \
2222
$(call image-tags,cozystack-operator,v$(COZYSTACK_VERSION)) \
2323
--build-arg VERSION=v$(COZYSTACK_VERSION) \
24-
--cache-from type=registry,ref=$(REGISTRY)/cozystack-operator:latest \
24+
--cache-from type=registry,ref=$(CACHE_REGISTRY)/cozystack-operator:latest \
2525
--cache-to type=inline \
2626
--metadata-file images/cozystack-operator.json \
2727
$(BUILDX_ARGS)

‎packages/core/platform/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ image: image-migrations
3030
image-migrations:
3131
docker buildx build images/migrations \
3232
$(call image-tags,platform-migrations,v$(COZYSTACK_VERSION)) \
33-
--cache-from type=registry,ref=$(REGISTRY)/platform-migrations:latest \
33+
--cache-from type=registry,ref=$(CACHE_REGISTRY)/platform-migrations:latest \
3434
--cache-to type=inline \
3535
--metadata-file images/migrations.json \
3636
$(BUILDX_ARGS)

‎packages/core/talos/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ image-matchbox:
2323
test -f ../../../_out/assets/initramfs-metal-amd64.xz || make talos-initramfs
2424
docker buildx build -f images/matchbox/Dockerfile ../../.. \
2525
$(call image-tags,matchbox,$(TALOS_VERSION)) \
26-
--cache-from type=registry,ref=$(REGISTRY)/matchbox:latest \
26+
--cache-from type=registry,ref=$(CACHE_REGISTRY)/matchbox:latest \
2727
--cache-to type=inline \
2828
--metadata-file images/matchbox.json \
2929
$(BUILDX_ARGS)

‎packages/core/testing/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ image: image-e2e-sandbox
1717
image-e2e-sandbox:
1818
docker buildx build -f images/e2e-sandbox/Dockerfile images/e2e-sandbox \
1919
$(call image-tags,e2e-sandbox,v$(COZYSTACK_VERSION)) \
20-
--cache-from type=registry,ref=$(REGISTRY)/e2e-sandbox:latest \
20+
--cache-from type=registry,ref=$(CACHE_REGISTRY)/e2e-sandbox:latest \
2121
--cache-to type=inline \
2222
--metadata-file images/e2e-sandbox.json \
2323
$(BUILDX_ARGS)

‎packages/extra/monitoring/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ generate:
1212
image:
1313
docker buildx build images/grafana \
1414
$(call image-tags,grafana,$(GRAFANA_TAG)) \
15-
--cache-from type=registry,ref=$(REGISTRY)/grafana:latest \
15+
--cache-from type=registry,ref=$(CACHE_REGISTRY)/grafana:latest \
1616
--cache-to type=inline \
1717
--metadata-file images/grafana.json \
1818
$(BUILDX_ARGS)

0 commit comments

Comments
 (0)