diff --git a/CLAUDE.md b/CLAUDE.md index 23d3799..2006f60 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -15,7 +15,7 @@ nachlesen, bevor eine davon in Frage gestellt wird. | Warum SSR statt WASM, warum PocketBase als Datenschicht, DynDNS und Proxy (AE-1 bis AE-6) | `docs/architektur.md` | | Stack lokal starten, Tests, compose-Overlays | `docs/entwicklung.md` | | Unraid, compose, NPM-Proxy-Host, Registry, Rollback | `docs/deployment.md` | -| Ist-Zustand auf Unraid: Container, Netzwerke, Ports | `docs/unraid-infrastructure.md` | +| Server allgemein: andere Container, Netzwerk-Muster, `proxynet`, NPM, Monitoring | Repo `Infrastructure`: — zum Entwickeln, Testen und Deployen **nicht** nötig | | Inhalte anlegen und ändern (PocketBase-Admin) | `docs/redaktion.md` | | Impressum, Datenschutz, Fotos | `docs/recht.md` | | Offene Arbeit, Meilensteine, offene Punkte | Gitea-Issues (Milestone „Elternbeirat-Website") | @@ -75,8 +75,7 @@ Inhalt liegt in PocketBase (`pb_data`), das separat gesichert wird (siehe gepflegt wird ausschließlich im PocketBase-Admin (Redakteure sind Superuser). - UI-Texte auf Deutsch, ohne Anglizismen. `Termine`, nicht `Events`. - Neue NuGet-Abhängigkeiten vorher begründen. Genutzt wird nur `Markdig` - (Markdown → HTML). `YamlDotNet` stammt aus der abgelösten Datei-Schicht, wird - nicht mehr verwendet und soll aus dem `csproj` entfernt werden. + (Markdown → HTML). ## Stil diff --git a/compose.yaml b/compose.yaml index c3c345f..00f626b 100644 --- a/compose.yaml +++ b/compose.yaml @@ -5,8 +5,8 @@ # NPM runs outside this stack (the `nginx` container on Unraid) and reaches both the # web app (eb-blazor:8080) and the PocketBase admin (eb-pocketbase:8090, for # redaktion.elternbeirat-igmh.info) by name over the external Docker network -# `proxynet`. No service publishes a host port: NPM is the only way in. Unraid -# setup: docs/unraid-infrastructure.md. +# `proxynet`. No service publishes a host port: NPM is the only way in. proxynet +# and the network pattern: Infrastructure repo, docs/networks.md. # # On Unraid this file is deployed as is by .gitea/workflows/deploy.yml (project # eb-stack), not pasted into the Compose Manager. diff --git a/docs/architektur.md b/docs/architektur.md index da25ca3..21b8441 100644 --- a/docs/architektur.md +++ b/docs/architektur.md @@ -87,16 +87,16 @@ the container has no port mapping and is reachable only through NPM. **Decision:** The A record of `elternbeirat-igmh.info` at Strato is kept current by `eb-ddns` ([ddns-updater](https://github.com/qdm12/ddns-updater)), a third service in `compose.yaml`. Its whole configuration is the `CONFIG` environment variable in -that file; only the DynDNS password comes from the stack's env -(`STRATO_DYNDNS_PASSWORD`). +that file; only the DynDNS password comes from outside, as the Gitea secret +`STRATO_DYNDNS_PASSWORD` that the deploy workflow passes in. **Rationale:** The site runs on the private connection, whose public IP changes. The FritzBox has a single DynDNS slot and it already serves `anticarnist.de`, so the update has to run elsewhere. Putting it in the stack means it moves with the site. ddns-updater was chosen over ddclient because of where the config lives: -ddclient needs a config file, which would have to sit next to the stack on the -server (the Unraid stack is maintained by hand, not from a checkout) and be set up -again whenever the container or its folder is deleted. ddns-updater takes the whole +ddclient needs a config file, which would have to sit on the server next to the +stack and be set up again whenever the container or its folder is deleted — the +deploy only brings `compose.yaml`, not further files. ddns-updater takes the whole config from one environment variable, so `compose.yaml` alone describes it and the container can be deleted and recreated without any setup — only the one secret stays outside the repo. diff --git a/docs/deployment.md b/docs/deployment.md index 9f5c5f9..06ff810 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -19,6 +19,27 @@ overlays layered on top. ## Prerequisites (one-time) +> Everything needed to deploy is in this repo. Background on the server as a +> whole (other containers, the network pattern, NPM) is in the Infrastructure +> repo, — helpful, not required. + +### Server: `proxynet` and NPM + +The deploy expects two things on Unraid that the stack does not create itself: + +1. The external Docker network `proxynet`, created once in the Unraid terminal: + + ```bash + docker network create proxynet + ``` + + It survives Docker restarts only with **Settings → Docker → Advanced View → + Preserve user defined networks: Yes**; otherwise `compose up` fails with + "network proxynet not found". +2. Nginx Proxy Manager attached to it (its container: **Network Type → Custom: + proxynet**), so it reaches `eb-blazor` and `eb-pocketbase` by name. The proxy + hosts themselves are below ("NPM proxy host", "Editor subdomain"). + ### Gitea registry token The push to the registry needs a Gitea access token with **package write @@ -34,7 +55,10 @@ permission** (`package: Read and Write`) — **not** the account password. > generate a new one. A `package` token allows uploading arbitrary images to the > registry. -The Docker login then stores the token locally, so it only has to be entered once. +The token goes into the repo secret `REGISTRY_TOKEN` (see "Automation"); the deploy +logs in with it on every run, so Unraid needs no `docker login` of its own. Only +the fallback `scripts/release.sh` needs a one-time `docker login +gitea.anticarnist.de` on the machine it runs on. ### DynDNS for elternbeirat-igmh.info (Strato) @@ -64,9 +88,12 @@ DynDNS password. right away; public resolvers follow once their cache expires. ```bash - dig +short @docks05.rzone.de elternbeirat-igmh.info + dig +short @217.160.80.132 elternbeirat-igmh.info ``` + `217.160.80.132` is `docks05.rzone.de`; the name itself does not resolve in the + LAN because AdGuard blocks `rzone.de` (Infrastructure repo, `docs/lan.md`). + **Testing the credentials without the container** — passing the IP the record already has, so a successful login changes nothing (`nochg`); `badauth` means domain or password are wrong: @@ -98,7 +125,8 @@ The NPM that already runs on Unraid fronts the site (why not one in the stack: | | HSTS Subdomains, DNS Challenge | off | NPM and `eb-blazor` share the Docker network `proxynet`, so NPM reaches the app by -container name; the app publishes no host port (`unraid-infrastructure.md`). +container name; the app publishes no host port (Infrastructure repo, +`docs/networks.md`). Let's Encrypt asks the Strato nameservers directly, so the certificate works as soon as DynDNS has updated, even while public resolvers still cache the old IP. @@ -134,9 +162,9 @@ The editors reach the PocketBase admin at The full URL is needed: with a bare path (`return 302 /_/;`) nginx adds its container port and the redirect lands on `:4443`. -Pitfalls: no `www.redaktion…` in Domain Names — it has no DNS record, and one -unknown name makes Let's Encrypt refuse the whole certificate. And no Custom -Location for `/`: an empty one without a forward target breaks the subdomain. +General NPM pitfalls hit while setting this up (an extra `www.redaktion…` in +Domain Names, an empty custom location, the `:4443` redirect) are in the +Infrastructure repo, `docs/proxy.md`. > **The whole PocketBase API is public on this subdomain, not just the admin.** > That is fine as long as the collection API rules only allow reading; writing is @@ -183,33 +211,23 @@ Pushes that only touch `docs/` or Markdown files trigger nothing. A manual run `scripts/release.sh` still builds and pushes by hand from `main`, as a fallback when the runner is down. It does not deploy. -### One-time switch from the Compose Manager - -Before the workflow took over, the stack was a Compose Manager stack -(`elternbeirat`) with a pasted copy of `compose.yaml`. The workflow runs the stack -as project `eb-stack`; the fixed `container_name`s would clash with the old -containers, so the old stack goes first: - -1. Add the secrets in Gitea (see "Automation" below). -2. Compose Manager → stack `elternbeirat` → **Compose Down**, then delete the - stack. `pb_data` is a bind mount and stays. -3. Run the workflow by hand. The site is down from step 2 until it finishes. - -From then on, a click on **Compose Up** in the Compose Manager is never needed — -and there is no stale copy left there that could be started by accident. - --- ## The compose files `compose.yaml` is the **production** base; the workflow deploys it to Unraid as -is. It defines -all services. `eb-blazor` publishes no host port and joins the external network -`proxynet`, so NPM is the only path to the web app. `eb-pocketbase` joins -`proxynet` too, for the editor subdomain, and publishes no host port either. -`eb-pocketbase` keeps its data on the bind mount +is. It defines all services. `eb-blazor` publishes no host port and joins the +external network `proxynet`, so NPM is the only path to the web app. +`eb-pocketbase` joins `proxynet` too, for the editor subdomain, and publishes no +host port either. `eb-pocketbase` keeps its data on the bind mount `/mnt/user/appdata/pocketbase/pb_data`, which only exists on the server. +The stack's own network has the fixed name `eb-internal`. Changing a network name +needs `docker compose down` and then `up`; a plain `up` fails because the existing +containers still point at the old network. `proxynet`, the network pattern and NPM +itself are server-wide and documented in the Infrastructure repo +(, `docs/networks.md`, `docs/proxy.md`). + The two overlays (`compose.dev.yaml`, `compose.test.yaml`) are for local development and the tests and are **not** used on Unraid — see `entwicklung.md`. @@ -272,10 +290,6 @@ Requires three repository secrets (Gitea → repo → **Settings** → **Actions login password. - `STRATO_DYNDNS_PASSWORD` — the DynDNS password for `eb-ddns` (see above). -Still open: the workflow does not run the tests yet, and a failed health gate -does not roll back on its own. - -Two known pitfalls: the `act_runner` needs Docker socket access to build, and it -must offer the `ubuntu-latest` label the workflow asks for. To check the runner: -Gitea → repo (or site admin) → **Settings** → **Actions** → **Runners** — it -should be listed as **online** with a label set that includes `ubuntu-latest`. +A failed health gate does not roll back on its own; that stays a deliberate step +(see "Rollback"). The runner itself (Docker socket, `ubuntu-latest` label) is +server-wide: Infrastructure repo, `docs/apps/gitea.md`. diff --git a/docs/entwicklung.md b/docs/entwicklung.md index fac8547..b57e659 100644 --- a/docs/entwicklung.md +++ b/docs/entwicklung.md @@ -16,7 +16,7 @@ the base for a local run — you layer an overlay on top of it. | File | Role | |---|---| -| `compose.yaml` | Base, production-shaped: both services, **no** host ports, PocketBase data on the Unraid bind mount. Also holds the fixed project name `eb-stack`. | +| `compose.yaml` | Base, production-shaped: all three services (`eb-pocketbase`, `eb-blazor`, `eb-ddns`), **no** host ports, PocketBase data on the Unraid bind mount, the external network `proxynet`. Also holds the fixed project name `eb-stack`. | | `compose.dev.yaml` | Dev overlay: adds host ports (5000, 8090), builds the web image from local source instead of pulling it, swaps the Unraid bind mount for a throwaway volume, seeds a local PocketBase superuser, and mounts `pb/pb_migrations` so a fresh volume is auto-seeded (see below). | | `compose.test.yaml` | Test overlay: used **only** by the integration tests. Drops the fixed host port and container names so a test run does not collide with a running dev stack, and removes the seed mount so the dev seed does not run during tests. | diff --git a/docs/unraid-infrastructure.md b/docs/unraid-infrastructure.md deleted file mode 100644 index e54d0bb..0000000 --- a/docs/unraid-infrastructure.md +++ /dev/null @@ -1,90 +0,0 @@ -# Unraid infrastructure - -What runs on the Unraid host and how the website stack fits in. This is the -**actual state** on the server. How to deploy a new version: `deployment.md`. - -## Host - -| | | -|---|---| -| LAN IP | `192.168.1.14` | -| Web UI | `https://unraid.server:44302` | -| Version | Unraid OS 7.0.1 | -| Stack management | Gitea Actions (`.gitea/workflows/deploy.yml`), no Compose Manager | -| Docker network for NPM | `proxynet` (created with `docker network create proxynet`) | - -**Settings → Docker → Advanced View → Preserve user defined networks: Yes.** -Without it Unraid deletes `proxynet` on every Docker restart, and every container -attached to it fails to start. - -## Website stack - -The stack is deployed by `.gitea/workflows/deploy.yml` as project `eb-stack`, -straight from the repo's `compose.yaml` (`deployment.md`). It is **not** a Compose -Manager stack: there is no copy of the compose file on the server. It shows up -on the Docker tab like any other container. - -The `Gitea-Runner` container runs the deploy. It has `/var/run/docker.sock` mounted, -so the workflow's `docker compose` talks to the Unraid daemon directly. - -> **Network names.** The stack's own network has the fixed name `eb-internal`. -> Changing a network name needs `docker compose down` and then `up`; a plain `up` -> fails because the existing containers still point at the old network. - -| Container | Network | Container port | Host port | -|---|---|---|---| -| `eb-blazor` | `eb-internal`, `proxynet` | `8080` | – | -| `eb-pocketbase` | `eb-internal`, `proxynet` | `8090` | – | -| `eb-ddns` | `eb-internal` | – | – | - -Persistent data: `/mnt/user/appdata/pocketbase/pb_data` → `/pb_data`. - -## Nginx Proxy Manager - -The container is called **`nginx`** and runs on the network `proxynet`. - -| Container port | Host port | -|---|---| -| `8080` (HTTP) | `80` | -| `4443` (HTTPS) | `443` | -| admin UI | `7818` (`http://192.168.1.14:7818`) | -| config | `/mnt/cache/appdata/nginx` → `/config` | - -> **Why `proxynet` and not `bridge`:** Docker's default `bridge` has no name -> resolution. On `proxynet` NPM reaches `eb-blazor:8080` by name, so the site needs -> no host port. - -### Active proxy hosts - -Except for the website stack, destinations use LAN host names (`unraid.server`), -resolved by the LAN DNS, never container IPs. That is why they kept working when -NPM moved from `bridge` to `proxynet`. - -| Source | Destination | SSL | -|---|---|---| -| `elternbeirat-igmh.info`, `www.elternbeirat-igmh.info` | `http://eb-blazor:8080` | Let's Encrypt | -| `redaktion.elternbeirat-igmh.info` | `http://eb-pocketbase:8090` (`/` → `/_/`) | Let's Encrypt | -| `gitea.anticarnist.de` | `http://unraid.server:3005` | Let's Encrypt | -| `cloud.anticarnist.de` | `https://unraid.server:44304` | Let's Encrypt | -| `home.anticarnist.de` | `http://unraid.server:44303` | Let's Encrypt | -| `assistant.anticarnist.de` | `http://192.168.1.15:8123` | Let's Encrypt | - -Further hosts (`*.katzenfunk.de`, `anticarnist.de` → `arch.server` / SearXNG) -exist but are offline and unused. - -## Other containers on the host - -Except for AdGuard, all of these run on `bridge` and have nothing to do with the -website. They are listed so it is clear which ports are taken. - -| Container | Host ports | -|---|---| -| AdGuard-Home | own IP `192.168.1.7` (`br0`) | -| flame | `44303` | -| Gitea | `2205` (SSH), `3005` (HTTP) | -| Gitea-Runner | – | -| nextcloud | `44304` | -| piper | `10200` | -| postgresql15 | `5432` | -| SearXNG | `1234` (stopped) | -| UptimeKuma | `3001` |