mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 11:46:35 +00:00
Two related improvements anchored on the same principle: the env var
INFINITO_DISTRO is the single source of truth for the development distro,
and INFINITO_CONTAINER is purely derived from it.
1. Fix the matrix-deploy purge failure (CI run 24942172018, job 73038526513,
web-app-wordpress @ fedora):
scripts/meta/env/defaults.sh eager-exported INFINITO_CONTAINER once
inside its load-once guard; ci/all.sh's iteration loop re-exported
INFINITO_DISTRO per round but the cached INFINITO_CONTAINER stayed at
the initial-default infinito_nexus_debian, so _purge_app_entities()
between rounds tried to docker exec into a container from the wrong
distro and failed with "No such container".
Move the INFINITO_CONTAINER derivation OUTSIDE the load-once guard so
every re-source picks up a CONTAINER name in lock-step with the current
INFINITO_DISTRO. ci/all.sh now re-sources defaults.sh after each
export INFINITO_DISTRO=\$distro to trigger that re-derivation. defaults.sh
stays the single spot that owns the formula.
2. Retire the --distro CLI arg from cli.deploy.development {up,down,stop,
restart,init,deploy,exec,logs,build}. The arg duplicated INFINITO_DISTRO
(its default already read from the env), creating a hidden second source
of truth that drifted from the env across matrix iterations. Replace it
with cli.deploy.development.common.resolve_distro() which reads
INFINITO_DISTRO strictly (raises SystemExit on unset/invalid), and
simplify make_compose() to take no args. All bash callers
(scripts/tests/deploy/{ci,local}/**, Makefile restart target) drop the
redundant --distro \"\${INFINITO_DISTRO}\" pass-through.
Verified: make test passes (1553 unit + 168 integration). The mechanism of
the WP fix is verified by a synthetic distro-cycling test of defaults.sh
re-derivation; the original CI multi-distro repro can only be confirmed
end-to-end by the next CI push (local single-distro deploys do not exercise
the stale-env path).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
83 lines
2.8 KiB
Python
83 lines
2.8 KiB
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import os
|
|
import subprocess
|
|
|
|
from .common import repo_root_from_here, resolve_distro
|
|
|
|
|
|
def add_parser(sub: argparse._SubParsersAction) -> None:
|
|
p = sub.add_parser(
|
|
"build", help="Build infinito image using scripts/image/build.sh (SPOT)."
|
|
)
|
|
p.add_argument("--missing", action="store_true", help="Build only if missing.")
|
|
p.add_argument("--no-cache", action="store_true", help="Build with --no-cache.")
|
|
p.add_argument("--target", help="Dockerfile target (e.g. virgin).", default="")
|
|
p.add_argument("--tag", help="Override output tag.", default="")
|
|
p.add_argument("--push", action="store_true", help="Push image (buildx).")
|
|
p.add_argument(
|
|
"--publish", action="store_true", help="Publish semantic tags (implies --push)."
|
|
)
|
|
p.add_argument("--registry", default="", help="Registry (e.g. ghcr.io).")
|
|
p.add_argument("--owner", default="", help="Owner/namespace (e.g. org/user).")
|
|
p.add_argument(
|
|
"--repo-prefix",
|
|
default="",
|
|
help="Repo prefix (default: current repository name).",
|
|
)
|
|
p.add_argument("--version", default="", help="Version (required for --publish).")
|
|
p.add_argument(
|
|
"--stable", choices=["true", "false"], default="", help="Publish stable tags."
|
|
)
|
|
|
|
p.set_defaults(_handler=handler)
|
|
|
|
|
|
def handler(args: argparse.Namespace) -> int:
|
|
repo_root = repo_root_from_here()
|
|
script = repo_root / "scripts" / "image" / "build.sh"
|
|
repository_name_script = (
|
|
repo_root / "scripts" / "meta" / "resolve" / "repository" / "name.sh"
|
|
)
|
|
|
|
env = dict(os.environ)
|
|
env["INFINITO_DISTRO"] = resolve_distro()
|
|
if not args.repo_prefix and not env.get("INFINITO_IMAGE_REPOSITORY"):
|
|
resolved_repo = subprocess.run(
|
|
[str(repository_name_script)],
|
|
cwd=repo_root,
|
|
env=env,
|
|
check=True,
|
|
capture_output=True,
|
|
text=True,
|
|
).stdout.strip()
|
|
env["INFINITO_IMAGE_REPOSITORY"] = resolved_repo
|
|
|
|
cmd: list[str] = [str(script)]
|
|
if args.missing:
|
|
cmd.append("--missing")
|
|
if args.no_cache:
|
|
cmd.append("--no-cache")
|
|
if args.target:
|
|
cmd += ["--target", args.target]
|
|
if args.tag:
|
|
cmd += ["--tag", args.tag]
|
|
if args.push:
|
|
cmd.append("--push")
|
|
if args.publish:
|
|
cmd.append("--publish")
|
|
if args.registry:
|
|
cmd += ["--registry", args.registry]
|
|
if args.owner:
|
|
cmd += ["--owner", args.owner]
|
|
if args.repo_prefix:
|
|
cmd += ["--repo-prefix", args.repo_prefix]
|
|
if args.version:
|
|
cmd += ["--version", args.version]
|
|
if args.stable:
|
|
cmd += ["--stable", args.stable]
|
|
|
|
r = subprocess.run(cmd, cwd=repo_root, env=env, check=False)
|
|
return int(r.returncode)
|