Add multi-site Caddy helpers and document usage
- add startup/shutdown scripts that render a Caddyfile from JSON config and run health checks - add Python utilities and a sample sites.json for declarative multi-site configuration - document the workflow and ignore generated Caddy state artifacts - normalize double-quote style across challenge workflow controllers, nodes, and tests
This commit is contained in:
parent
a99e716ad2
commit
6038fc25f5
26 changed files with 1018 additions and 168 deletions
29
docker/caddy/load_metadata.py
Normal file
29
docker/caddy/load_metadata.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"""Load site metadata without rewriting the Caddyfile."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
from .render_caddy import SiteMetadata, _expand, _to_bool
|
||||
|
||||
|
||||
def load_metadata(config_path: Path) -> List[SiteMetadata]:
|
||||
with config_path.open("r", encoding="utf-8") as fh:
|
||||
data = json.load(fh)
|
||||
|
||||
sites = data.get("sites", [])
|
||||
metadata: List[SiteMetadata] = []
|
||||
for raw_site in sites:
|
||||
site = _expand(raw_site)
|
||||
health_cfg = site.get("health_check") or {}
|
||||
metadata.append(
|
||||
SiteMetadata(
|
||||
name=site.get("name", "site"),
|
||||
health_url=health_cfg.get("url", ""),
|
||||
skip_healthcheck=_to_bool(health_cfg.get("skip"), default=False),
|
||||
app_url=site.get("app_url", ""),
|
||||
)
|
||||
)
|
||||
return metadata
|
||||
Loading…
Add table
Add a link
Reference in a new issue