From 11a2d08e4c864699384cba7493a20601902282f8 Mon Sep 17 00:00:00 2001 From: Jiri Uhlir Date: Wed, 3 Jun 2026 10:49:34 +0200 Subject: [PATCH] Generate app ports in catalog and gateway --- scripts/generate-caddyfile.sh | 44 ++++++++++++++++++++++++++++------- scripts/generate-catalog.sh | 31 +++++++++++++++++++++--- 2 files changed, 63 insertions(+), 12 deletions(-) diff --git a/scripts/generate-caddyfile.sh b/scripts/generate-caddyfile.sh index 99f302e..32b3aef 100755 --- a/scripts/generate-caddyfile.sh +++ b/scripts/generate-caddyfile.sh @@ -29,16 +29,42 @@ cat > "$CADDY_FILE" <> "$CADDY_FILE" +catalog_file = sys.argv[1] +caddy_file = sys.argv[2] + +apps = [] +current = None + +with open(catalog_file, "r", encoding="utf-8") as f: + for raw in f: + stripped = raw.strip() + + if stripped.startswith("- id:"): + if current: + apps.append(current) + current = {"id": stripped.split(":", 1)[1].strip()} + elif current and ":" in stripped: + key, value = stripped.split(":", 1) + current[key.strip()] = value.strip().strip('"') + +if current: + apps.append(current) + +with open(caddy_file, "a", encoding="utf-8") as f: + for app in apps: + app_id = app.get("id") + port = app.get("container_port") or app.get("port") or "8000" + + if not app_id: + continue + + f.write(f" handle_path /apps/{app_id}/* {{\n") + f.write(f" reverse_proxy {app_id}:{port}\n") + f.write(" }\n\n") +PY fi cat >> "$CADDY_FILE" <