From c480c748ea25313c021c95ee61bb5574998bc205 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Mon, 5 Oct 2026 00:20:53 +0200 Subject: [PATCH] fix(docs): name the image the run resolved instead of a frozen reference The published Production block hardcoded ghcr.io/infinito-nexus/core/debian, which duplicates the template meta/distros.yml declares and points every reader at :latest. That index carries linux/amd64 and an attestation, so the docs CLI test, which executes the published instructions verbatim, died on arm64 with `no matching manifest for linux/arm64/v8`. deploy_image() prefers INFINITO_IMAGE, which scripts/tests/deploy/ci/one.sh already exports from resolve/image/ci.sh, and otherwise composes the reference through environment_image() from the distro and tag default.env declares and the owner and repository SOFTWARE_REPOSITORY carries. The default is byte-identical to the literal it replaces. Nothing versioned becomes environment-dependent: the Quick Setup block is never committed, and roles/web-app-docs rebuilds it inside the container, where builder.py puts the snapshot first on PYTHONPATH and passes os.environ through. CI therefore tests the instructions against the image the run just built rather than against a release from months ago. Co-Authored-By: Claude Opus 5 (1M context) --- cli/build/docs/readme/generate.py | 3 ++- cli/build/docs/readme/schema.py | 1 + roles/web-app-docs/templates/env.j2 | 1 + templates/roles/README.md.j2.tmpl | 2 +- utils/software.py | 25 +++++++++++++++++++++++++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/cli/build/docs/readme/generate.py b/cli/build/docs/readme/generate.py index 839fd91c96..982feecf87 100644 --- a/cli/build/docs/readme/generate.py +++ b/cli/build/docs/readme/generate.py @@ -34,7 +34,7 @@ from utils.roles.entity.name import entity_name from utils.roles.mapping import ROLE_FILE_META_MAIN, ROLE_FILE_README from utils.roles.meta_lookup import get_role_guide_companions from utils.roles.validation.invokable import _get_invokable_paths, _is_role_invokable -from utils.software import SOFTWARE_REPOSITORY +from utils.software import SOFTWARE_REPOSITORY, deploy_image from utils.symbol_glossary import to_emoji MANAGED_SECTIONS = ("Cosmos", "Quick Setup", "Credits") @@ -104,6 +104,7 @@ def _base_context(role_dir, role_name: str, app_name: str, *, invokable: bool) - [role_name, *get_role_guide_companions(role_dir, role_name=role_name)] ), "software_repository": SOFTWARE_REPOSITORY, + "application_deploy_image": deploy_image(), "cosmos_mermaid": derive_cosmos_mermaid(role_dir, role_name), "cosmos_legend": _cosmos_legend(), } diff --git a/cli/build/docs/readme/schema.py b/cli/build/docs/readme/schema.py index e4f27be012..4ab690fc1a 100644 --- a/cli/build/docs/readme/schema.py +++ b/cli/build/docs/readme/schema.py @@ -31,6 +31,7 @@ _REQUIRED_CTX: dict = { "application_author": "Kevin Veen-Birkenbach", "cosmos_mermaid": 'flowchart LR\n a["a"] --> b["b"]', "software_repository": SOFTWARE_REPOSITORY, + "application_deploy_image": "ghcr.io/example/core/debian:latest", } _OPTIONAL_CTX: dict = { diff --git a/roles/web-app-docs/templates/env.j2 b/roles/web-app-docs/templates/env.j2 index e3643dc6ab..09c144bab3 100644 --- a/roles/web-app-docs/templates/env.j2 +++ b/roles/web-app-docs/templates/env.j2 @@ -6,3 +6,4 @@ DOCS_BUILD_JOBS={{ DOCS_BUILD_JOBS }} DOCS_FETCH_INTERVAL={{ DOCS_FETCH_INTERVAL }} DOCS_PORT={{ DOCS_PORT }} DOCS_SNAPSHOT_DIR={{ DOCS_SNAPSHOT_DIR }} +INFINITO_IMAGE={{ lookup('env', 'INFINITO_IMAGE') | dotenv_quote }} diff --git a/templates/roles/README.md.j2.tmpl b/templates/roles/README.md.j2.tmpl index 87167442fe..c1f1ef8fd5 100644 --- a/templates/roles/README.md.j2.tmpl +++ b/templates/roles/README.md.j2.tmpl @@ -118,7 +118,7 @@ SSH_PUBLIC_KEY="" docker run --rm -it \ -v "$PWD/inventories:/etc/infinito.nexus/inventories" \ -e APP="$APP" -e HOST="$HOST" -e DOMAIN="$DOMAIN" {% if application_needs_clearnet_resolver %}-e DNS="$DNS" {% endif %}-e TLS_MODE="$TLS_MODE" -e SSH_PUBLIC_KEY="$SSH_PUBLIC_KEY" \ - ghcr.io/infinito-nexus/core/debian bash -c ' + {{ application_deploy_image }} bash -c ' INVENTORY=/etc/infinito.nexus/inventories/production infinito administration inventory provision "$INVENTORY" \ --inventory-file "$INVENTORY/devices.yml" \ diff --git a/utils/software.py b/utils/software.py index df808caf66..4f2baf0ab7 100644 --- a/utils/software.py +++ b/utils/software.py @@ -2,8 +2,12 @@ from __future__ import annotations +import os + from utils.cache.files import PROJECT_ROOT from utils.cache.yaml import load_yaml +from utils.distros import environment_image +from utils.env.parser import parse_static_env SOFTWARE_VARS = PROJECT_ROOT / "group_vars" / "all" / "00_general.yml" SOFTWARE_NAME: str = load_yaml(str(SOFTWARE_VARS))["SOFTWARE_NAME"] @@ -13,3 +17,24 @@ SOFTWARE_EMAIL = "kevinveenbirkenbach@infinito.nexus" SOFTWARE_URL = "https://infinito.nexus" SOFTWARE_CONTACT = "contact@infinito.nexus" SOFTWARE_LICENSE = "Infinito.Nexus Community License (Non-Commercial)" +DEPLOY_IMAGE_ENV = "INFINITO_IMAGE" + + +def deploy_image() -> str: + """Reference of the image the published deploy instructions tell a reader to run. + + Returns: + The ``INFINITO_IMAGE`` the run resolved for itself when set, otherwise + the environment image of the distro and tag ``default.env`` declares, + under the owner and repository of ``SOFTWARE_REPOSITORY``. + """ + if override := os.environ.get(DEPLOY_IMAGE_ENV): + return override + declared = parse_static_env(PROJECT_ROOT / "default.env") + owner, repository = SOFTWARE_REPOSITORY.removesuffix(".git").rsplit("/", 2)[-2:] + return environment_image( + declared["INFINITO_DISTRO"], + owner, + repository, + declared["INFINITO_IMAGE_TAG"], + )