mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-06 23:23:23 +09:00
build(hack): add OCI_EXPORT_DIR archive-export build mode
When OCI_EXPORT_DIR is set, every image builds to a per-image OCI archive (<dir>/<name>.oci.tar) instead of being pushed, and PUSH/LOAD are forced off. This lets a credential-less build (a fork PR's pull_request run) produce the images as artifacts that a privileged workflow later pushes to the registry by digest. The image digest is captured via --metadata-file regardless of output type, so the values.yaml/.tag refs baked during the build match exactly what the privileged run pushes. The output flag is threaded through the image-tags macro, which every package's buildx call already uses, so no per-package Makefile change is needed. Refs: #3257 Assisted-By: Claude <noreply@anthropic.com> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
This commit is contained in:
1 parent
cc44f6c981
commit
529efa7e01
1 file changed
+24
-1
+24
-1
@@ -36,6 +36,23 @@ WRITE_CACHE ?= 0
|
||||
|
||||
PUSH := 1
|
||||
LOAD := 0
|
||||
|
||||
# OCI_EXPORT_DIR: when set, build every image to a per-image OCI archive
|
||||
# (<dir>/<name>.oci.tar) instead of pushing or loading it. Fork PRs use this:
|
||||
# the unprivileged `pull_request` build carries no registry credentials, so it
|
||||
# exports the images as workflow artifacts and a privileged `workflow_run` later
|
||||
# pushes them to the registry BY DIGEST (see .github/workflows/e2e-fork.yaml).
|
||||
# The image digest is content-addressed and captured via --metadata-file
|
||||
# regardless of output type, so the values.yaml/.tag refs baked during this
|
||||
# build match exactly what the privileged run pushes. Setting it forces
|
||||
# PUSH/LOAD off so buildx emits only the archive — a `--push` alongside the OCI
|
||||
# --output would attempt an anonymous push and die with `denied` (#3257).
|
||||
OCI_EXPORT_DIR ?=
|
||||
ifneq ($(strip $(OCI_EXPORT_DIR)),)
|
||||
PUSH := 0
|
||||
LOAD := 0
|
||||
endif
|
||||
|
||||
BUILDER ?=
|
||||
PLATFORM ?=
|
||||
BUILDX_EXTRA_ARGS ?=
|
||||
@@ -65,8 +82,14 @@ BUILDX_ARGS := --provenance=false --push=$(PUSH) --load=$(LOAD) \
|
||||
# Consumers reference images by digest, so the build-unique tag is enough
|
||||
# for cluster-side pulls; the versioned and floating tags exist for human
|
||||
# discoverability and downstream tooling on releases.
|
||||
# When OCI_EXPORT_DIR is set it also appends a per-image `--output type=oci`
|
||||
# so the build writes <dir>/<name>.oci.tar (the tag becomes the archive's image
|
||||
# name). Every package's buildx call routes its tags through this macro, so this
|
||||
# is the single point that turns the whole build into an artifact-export build.
|
||||
# $(comma) escapes the literal comma so make does not read it as an $(if …)
|
||||
# argument separator; it is defined below and resolves at $(call) time.
|
||||
define image-tags
|
||||
--tag $(REGISTRY)/$(1):$(IMAGE_TAG)$(if $(filter 1,$(PUBLISH_VERSIONED)),$(if $(filter-out $(IMAGE_TAG),$(strip $(2))), --tag $(REGISTRY)/$(1):$(strip $(2))))$(if $(filter 1,$(PUBLISH_FLOATING)), --tag $(REGISTRY)/$(1):latest)
|
||||
--tag $(REGISTRY)/$(1):$(IMAGE_TAG)$(if $(filter 1,$(PUBLISH_VERSIONED)),$(if $(filter-out $(IMAGE_TAG),$(strip $(2))), --tag $(REGISTRY)/$(1):$(strip $(2))))$(if $(filter 1,$(PUBLISH_FLOATING)), --tag $(REGISTRY)/$(1):latest)$(if $(strip $(OCI_EXPORT_DIR)), --output type=oci$(comma)dest=$(OCI_EXPORT_DIR)/$(subst /,-,$(1)).oci.tar)
|
||||
endef
|
||||
|
||||
# cache-args <image-name> [<cache-tag>]
|
||||
|
||||
Reference in new issue
Block a user