From f6f8f41649b8dc41b821bd58d75f00bc10dcb3a2 Mon Sep 17 00:00:00 2001 From: Archipelago automation Date: Wed, 4 Nov 2026 20:27:58 +0000 Subject: [PATCH] Route Archipelago through Moscow ingress proxies --- README.md | 12 +++++++ deploy/integrate-ingress.py | 69 +++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 deploy/integrate-ingress.py diff --git a/README.md b/README.md index 570f9ca..a8a5590 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,18 @@ artwork require no remote fonts, scripts or upstream logo redistribution. ## Remaining pipeline work +### External ingress + +For the known Moscow Docker Caddy ingress sites, run as root: +`python3 deploy/integrate-ingress.py /path/to/conf/Caddyfile`. +The helper inserts `/archipelago` and `/archipelago/*` routes into the single +`mirror.nw-sys.ru` block, forwarding to terra at `100.64.0.1:80`. It validates +inside `caddy-caddy-1`, saves a restricted backup and restores on reload failure. +Host paths: south `/app/caddy/conf/Caddyfile`, north +`/home/no1_tx/apps/caddy/conf/Caddyfile`, west `/opt/caddy/conf/Caddyfile`. + +### Build and update pipeline + The existing CLI ISO experiment is not yet a YAML-driven, independently built layer pipeline. Required sequence: strict Layer parser and locks → independent layer build → artifact upload → image composition from registry → ISO from exact image → diff --git a/deploy/integrate-ingress.py b/deploy/integrate-ingress.py new file mode 100644 index 0000000..6b1ecdd --- /dev/null +++ b/deploy/integrate-ingress.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 +"""Add the Archipelago route to a known Docker Caddy ingress configuration.""" +from pathlib import Path +import os +import re +import shutil +import subprocess +import sys +import time + +config = Path(sys.argv[1]) +original = config.read_bytes() +text = original.decode() +sites = list(re.finditer(r'^mirror\.nw-sys\.ru \{\n.*?^\}', text, re.M | re.S)) +if len(sites) != 1: + raise SystemExit('Expected exactly one standalone mirror site block') +site = sites[0] +block = site.group() +if '/archipelago' in block: + raise SystemExit('Archipelago route already present; review explicitly') +marker = ' handle /archlinux* {' +if block.count(marker) != 1 or 'reverse_proxy http://100.64.0.1:80' not in block: + raise SystemExit('Unexpected mirror routing; review explicitly') +snippet = ''' # BEGIN ARCHIPELAGO ingress + handle /archipelago { + redir /archipelago/ 308 + } + handle /archipelago/* { + reverse_proxy http://100.64.0.1:80 + } + # END ARCHIPELAGO ingress + +''' +candidate = (text[:site.start()] + block.replace(marker, snippet + marker) + + text[site.end():]).encode() +temporary = config.with_name(f'Caddyfile.archipelago-candidate-{time.time_ns()}') +command = ['docker', 'exec', 'caddy-caddy-1', 'caddy'] + +def write(data): + with config.open('wb') as stream: + stream.write(data) + stream.flush() + os.fsync(stream.fileno()) + +def reload(): + subprocess.run(command + ['reload', '--config', '/etc/caddy/Caddyfile', + '--adapter', 'caddyfile'], check=True) + +try: + with temporary.open('xb') as stream: + os.fchmod(stream.fileno(), 0o600) + stream.write(candidate) + subprocess.run(command + ['validate', '--config', '/etc/caddy/' + temporary.name, + '--adapter', 'caddyfile'], check=True) + if config.read_bytes() != original: + raise SystemExit('Configuration changed during validation; retry after review') + backup = config.with_name(f'Caddyfile.before-archipelago-{time.time_ns()}') + shutil.copy2(config, backup) + os.chmod(backup, 0o600) + try: + write(candidate) + reload() + except Exception: + write(original) + reload() + raise + print(f'Integrated ingress; backup: {backup}') +finally: + temporary.unlink(missing_ok=True)