diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 9efc232..425c791 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -1,25 +1,41 @@ -# Builds the production image on every push to main and pushes it to the Gitea -# registry, tagged with :latest AND the short commit SHA (for rollback) -- the -# same tagging scheme as scripts/release.sh, but run by the act_runner instead -# of by hand. +# Builds the production image on every push to main, pushes it to the Gitea +# registry (tagged :latest AND the short commit SHA, for rollback) and deploys the +# stack on Unraid from the repo's compose.yaml -- the repo is the only copy of the +# compose file; there is no duplicate in the Compose Manager. # -# It does NOT deploy: pulling and starting the new :latest on Unraid stays a -# manual, deliberate step (Compose Down/Up). Auto-deploy via Watchtower is an -# open item in docs/deployment.md and needs a health gate first, so a broken -# page can never go live unnoticed. +# The deploy works because the act_runner runs ON Unraid and hands its Docker +# socket to the job: every `docker` command here talks to the Unraid daemon, so +# absolute paths in compose.yaml (the pb_data bind mount) are host paths. +# +# `docker compose up -d` only recreates containers whose image or config changed: +# a new image restarts eb-blazor for a few seconds, eb-pocketbase and eb-ddns keep +# running. Content lives in PocketBase and is never touched by a deploy. # # Required repository secrets (Gitea -> repo -> Settings -> Actions -> Secrets): -# REGISTRY_USER the registry username (e.g. Tom) -# REGISTRY_TOKEN a Gitea access token with package:write -- NOT the password +# REGISTRY_USER the registry username (e.g. Tom) +# REGISTRY_TOKEN a Gitea access token with package:write -- NOT the password +# STRATO_DYNDNS_PASSWORD the DynDNS password for eb-ddns (docs/deployment.md) -name: Build and push image +name: Build and deploy on: push: branches: [main] + # Docs alone change neither the image nor the stack. + paths-ignore: + - "docs/**" + - "**/*.md" + # Manual run from Gitea (Actions tab), e.g. to redeploy after a server restart. + workflow_dispatch: + +# Two quick pushes must not deploy over each other; the later one waits. +concurrency: + group: deploy + cancel-in-progress: false env: IMAGE: gitea.anticarnist.de/tom/elternbeirat + COMPOSE_VERSION: v2.39.4 jobs: build: @@ -52,3 +68,54 @@ jobs: tags: | ${{ env.IMAGE }}:latest ${{ env.IMAGE }}:${{ steps.sha.outputs.short }} + + deploy: + needs: build + runs-on: ubuntu-latest + steps: + - name: Check out the source + uses: actions/checkout@v4 + + # The job image ships the Docker CLI (the build needs it) but not + # necessarily the compose plugin; install a pinned one if it is missing. + - name: Ensure docker compose + run: | + docker compose version && exit 0 + mkdir -p ~/.docker/cli-plugins + curl -fsSL -o ~/.docker/cli-plugins/docker-compose \ + "https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-linux-x86_64" + chmod +x ~/.docker/cli-plugins/docker-compose + docker compose version + + # The image is private; the pull below runs with this job's login. + - name: Log in to the Gitea registry + uses: docker/login-action@v3 + with: + registry: gitea.anticarnist.de + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_TOKEN }} + + # An explicit pull: `up` alone keeps a local :latest and would not notice + # the image the build job just pushed. + - name: Pull and start the stack + env: + STRATO_DYNDNS_PASSWORD: ${{ secrets.STRATO_DYNDNS_PASSWORD }} + run: | + docker compose -f compose.yaml pull + docker compose -f compose.yaml up -d --wait --remove-orphans + + # /health answers 200 only when the app runs AND reaches PocketBase. It is + # checked from inside proxynet, the same way NPM reaches the app. A failure + # marks the run red; the rollback stays a deliberate step (docs/deployment.md). + - name: Health gate + run: | + for attempt in $(seq 1 30); do + if docker run --rm --network proxynet busybox:1.37 \ + wget -qO- http://eb-blazor:8080/health; then + exit 0 + fi + sleep 2 + done + echo "eb-blazor did not report healthy within 60 seconds." >&2 + docker logs --tail 50 eb-blazor >&2 + exit 1 diff --git a/CLAUDE.md b/CLAUDE.md index 9fd5eec..23d3799 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -12,9 +12,10 @@ nachlesen, bevor eine davon in Frage gestellt wird. | Thema | Datei | |---|---| -| Warum SSR statt WASM, warum PocketBase als Datenschicht (AE-1 bis AE-4) | `docs/architektur.md` | +| 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` | | 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") | diff --git a/compose.dev.yaml b/compose.dev.yaml index c5afe1f..cf03ded 100644 --- a/compose.dev.yaml +++ b/compose.dev.yaml @@ -10,6 +10,9 @@ services: eb-pocketbase: + # The base's `restart: always` is for Unraid; locally the stack should not come + # back on its own after a reboot of the dev machine. + restart: "no" ports: - "8090:8090" # PocketBase admin UI at http://localhost:8090/_/ environment: @@ -36,11 +39,28 @@ services: # changes show up without a push+CI round-trip. image: "" clears the inherited # tag from the base, which forces compose to use the build below. image: "" + restart: "no" build: context: . dockerfile: Dockerfile ports: - "5000:8080" # web app at http://localhost:5000 + eb-ddns: + # Never update the public DNS from a dev machine. A profile nobody enables keeps + # the service out of `up`. + profiles: [disabled] + +networks: + default: + # Back to the project-derived name (eb-stack_default, eb-test-stack_default), so + # the dev and test stacks don't share one network and the tests' `down` does not + # try to remove the network the dev stack still uses. + name: !reset null + proxynet: + # The base expects NPM's network on Unraid. Locally there is no NPM, so compose + # creates a project-local network instead of failing on the missing external one. + external: false + volumes: pb_data_dev: # throwaway local volume; remove with `docker volume rm` diff --git a/compose.yaml b/compose.yaml index 4574716..87576bb 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,15 +1,21 @@ -# Base compose: production-like. Both services; only PocketBase's data is a volume, -# everything else lives inside the images. +# Base compose: production-like. PocketBase, the web app and the DynDNS updater; +# only PocketBase's data is a volume, everything else lives inside the images or +# in this file. # -# The two `ports:` blocks below are TEMPORARY. The target state is NPM in front: -# NPM terminates TLS and is the only path to the web app, and the editors reach -# PocketBase through an NPM subdomain (#9). NPM still needs a target address and -# port, so a port stays reachable either way -- the plan is to reach the containers -# by name over a shared Docker network (e.g. eb-blazor:8080) instead of publishing -# them on the LAN, and to drop these host mappings that expose the site and admin UI -# to anyone on the LAN. While NPM is not set up yet, these mappings are the only way -# onto the site and the admin UI. +# NPM runs outside this stack (the `nginx` container on Unraid) and reaches the web +# app by name over the external Docker network `proxynet` (eb-blazor:8080), so the +# web app publishes no host port. The `ports:` block on PocketBase is TEMPORARY: it +# is the editors' way onto the admin UI until they reach it through an NPM subdomain +# (#9). Unraid setup: docs/unraid-infrastructure.md. # +# On Unraid this file is deployed as is by .gitea/workflows/deploy.yml (project +# eb-stack), not pasted into the Compose Manager. +# +# `restart: always`, not `unless-stopped`: Unraid stops every container explicitly +# when Docker or the array goes down, and `unless-stopped` treats that as a manual +# stop -- the stack would stay down after a reboot. Without the Compose Manager +# there is no autostart toggle to bring it back. + # For local development use the dev overlay on top, which adds host ports and builds # the web image from source: # docker compose -f compose.yaml -f compose.dev.yaml up --build @@ -27,7 +33,7 @@ services: eb-pocketbase: image: ghcr.io/muchobien/pocketbase:0.40.4 container_name: eb-pocketbase - restart: unless-stopped + restart: always environment: TZ: Europe/Berlin volumes: @@ -49,7 +55,7 @@ services: eb-web: image: gitea.anticarnist.de/tom/elternbeirat:latest container_name: eb-blazor - restart: unless-stopped + restart: always depends_on: eb-pocketbase: condition: service_healthy @@ -58,9 +64,37 @@ services: TZ: Europe/Berlin # The web app reads content from PocketBase over the compose network. PocketBase__BaseUrl: http://eb-pocketbase:8090 - ports: - # TEMPORARY: reach the site on the LAN (http://:5000) while NPM is not - # in front yet. Replace once NPM terminates TLS and fronts the site (#9): join - # the external NPM network and let NPM point at eb-blazor:8080 by name, so this - # host mapping can go and the site is no longer open on the LAN. - - "5000:8080" + networks: + # default: reach eb-pocketbase. proxynet: be reached by NPM as eb-blazor:8080. + - default + - proxynet + + eb-ddns: + # Keeps the A record of elternbeirat-igmh.info at Strato pointed at the current + # public IP of the connection. The FritzBox can't do it: its single DynDNS slot + # already serves anticarnist.de. www is a CNAME on the domain and follows on its + # own. The whole config lives here in CONFIG, so the container needs no config + # file and no volume -- only the password comes from the stack's env + # (STRATO_DYNDNS_PASSWORD, never in the repo). The ":-" default keeps dev and + # tests quiet, where the service is disabled. Setup: docs/deployment.md. + image: qmcgaw/ddns-updater:2.10 + container_name: eb-ddns + restart: always + environment: + TZ: Europe/Berlin + PERIOD: 5m + CONFIG: >- + {"settings":[ + {"provider":"strato","domain":"elternbeirat-igmh.info","password":"${STRATO_DYNDNS_PASSWORD:-}","ip_version":"ipv4"} + ]} + +networks: + default: + # A fixed name instead of the project-derived one: the Compose Manager names the + # project after the stack folder (elternbeirat_default otherwise). Changing it + # needs Compose Down + Up; a plain Up leaves containers on the old network. + name: eb-internal + proxynet: + # Created once on Unraid (`docker network create proxynet`) and shared with NPM. + # The dev overlay turns it into a local network, so no machine but Unraid needs it. + external: true diff --git a/docs/architektur.md b/docs/architektur.md index c0a00d0..da25ca3 100644 --- a/docs/architektur.md +++ b/docs/architektur.md @@ -82,6 +82,44 @@ to the outside. NPM terminates TLS and is the only path to the container. `UseForwardedHeaders` with emptied `KnownNetworks`/`KnownProxies` is correct because the container has no port mapping and is reachable only through NPM. +## AE-5: DynDNS as a container in the stack (ddns-updater) + +**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`). + +**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 +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. + +**Consequence:** No volume, so ddns-updater keeps no update history across +recreations; it just checks the IP again on start. The dev overlay disables the +service, so a local `up` never changes the public DNS. Setup: +`deployment.md`. + +## AE-6: No proxy in the stack + +**Decision:** NPM is **not** part of `eb-stack`. The site uses the NPM that already +runs on Unraid. + +**Rationale:** A host has only one 80/443, and the router forwards it to one target. +A second NPM in the stack would collide with the existing one, which also serves +`anticarnist.de`. Which proxy owns 80/443 is a property of the host, not of the +site. + +**Consequence:** Moving the site to another host means setting up a proxy there and +recreating one proxy host (domain → app, Let's Encrypt). The steps are in +`deployment.md`. + ## Rejected alternatives (for AE-1) | Alternative | Why not | diff --git a/docs/deployment.md b/docs/deployment.md index a580c9e..a202326 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -1,12 +1,14 @@ # Deployment -How a new version of the website ends up on Unraid. Current state: -**manual** — build the image locally, push it to the Gitea registry, pull it on -Unraid. Automation via Gitea Actions comes later. +How a new version of the website ends up on Unraid: a merge to `main` runs +`.gitea/workflows/deploy.yml`, which builds the image, pushes it to the Gitea +registry and starts the stack on Unraid from the repo's `compose.yaml`. Nothing is +copied or pasted by hand. -The site runs as a **two-container stack** (project `eb-stack`): the Blazor app -(`eb-blazor`) plus a PocketBase container (`eb-pocketbase`) that holds the -content. The stack is described by `compose.yaml` (the production base) with +The site runs as a **three-container stack** (project `eb-stack`): the Blazor app +(`eb-blazor`), a PocketBase container (`eb-pocketbase`) that holds the content, +and a DynDNS updater (`eb-ddns`) that keeps the domain pointed at the +connection. The stack is described by `compose.yaml` (the production base) with overlays layered on top. > **Running it locally is a separate document.** For starting the stack on your @@ -34,6 +36,73 @@ permission** (`package: Read and Write`) — **not** the account password. The Docker login then stores the token locally, so it only has to be entered once. +### DynDNS for elternbeirat-igmh.info (Strato) + +The domain is registered at **Strato**; the site runs on the private connection, +whose public IP changes. `eb-ddns` ([ddns-updater](https://github.com/qdm12/ddns-updater)) +reports the current IP to Strato every five minutes. Why a container and why +ddns-updater: `architektur.md`, AE-5. + +The whole updater config sits in `compose.yaml` (`CONFIG`), so deleting and +recreating the container needs no setup. The only thing outside the repo is the +DynDNS password. + +1. **Strato** customer area → domain `elternbeirat-igmh.info` → DNS settings → + **Dynamic DNS** → activate. `www` needs nothing: it is a CNAME on the domain + and follows on its own. +2. **Strato password:** DynDNS accepts the package password **or** a separate + DynDNS password, set under **Security → Set passwords** (not under Dynamic + DNS). Use the separate one — the package password also opens the webspace. +3. **Gitea** → repo → **Settings** → **Actions** → **Secrets**: add + `STRATO_DYNDNS_PASSWORD`. The deploy hands it to compose, which fills it into + `CONFIG`. The password ends up inside JSON, so it must not contain `"` or `\`; + avoid `$` and `#` as well. +4. Run the workflow (**Actions** → **Build and deploy** → **Run workflow**). + `docker logs eb-ddns` shows `Updating record … to use ` with no `ERROR` + after it. +5. Check: the Strato nameservers answer with the public IP of the connection + right away; public resolvers follow once their cache expires. + + ```bash + dig +short @docks05.rzone.de elternbeirat-igmh.info + ``` + +**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: + +```bash +curl -u elternbeirat-igmh.info "https://dyndns.strato.com/nic/update?hostname=elternbeirat-igmh.info&myip=" +``` + +> **The DynDNS password is a secret** like the registry token: only as a Gitea +> secret, never in Git. A missing value does not stop the stack; it +> shows up as a failed update in `docker logs eb-ddns`. The dev overlay disables +> `eb-ddns`, so a local `up` never touches the public DNS. + +### NPM proxy host + +The NPM that already runs on Unraid fronts the site (why not one in the stack: +`architektur.md`, AE-6). The router forwards 80/443 to it. + +**Hosts → Proxy Hosts → Add Proxy Host:** + +| Tab | Field | Value | +|---|---|---| +| Details | Domain Names | `elternbeirat-igmh.info`, `www.elternbeirat-igmh.info` | +| | Scheme / Forward Hostname / Port | `http` / `eb-blazor` / `8080` | +| | Block Common Exploits | on | +| | Cache Assets, Websockets Support | off | +| SSL | SSL Certificate | Request a new SSL Certificate (Let's Encrypt) | +| | Force SSL, HTTP/2, HSTS | on | +| | 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`). +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. + --- ## Way of working: branches, never directly on main @@ -52,80 +121,57 @@ dev stack (`entwicklung.md`) — it builds the web image from source and pushes nothing, so a development state can never accidentally land in the registry as `:latest`. -## Rolling out a new version (manual) +## Rolling out a new version -Prerequisite: logged in to the registry once (see below). Then, **on main** and -with a clean working directory: +Merge the pull request into `main`. The workflow then: -```bash -scripts/release.sh -``` +1. builds the image and pushes it as `:latest` **and** `:` (rollback), +2. pulls it on Unraid and runs `docker compose up -d` with the repo's + `compose.yaml` — only containers whose image or config changed are recreated, +3. checks `http://eb-blazor:8080/health` from inside `proxynet` (health gate). A + red run means the new version is live but not healthy: roll back (below). -The script builds the image, tags it with `:latest` **and** the short commit SHA -(for rollback), and pushes both. It **aborts** if you are not on `main` or have -uncommitted changes, and warns about unpushed commits. +Pushes that only touch `docs/` or Markdown files trigger nothing. A manual run +(**Actions** → **Build and deploy** → **Run workflow**) redeploys the current +`main`. > The image path `gitea.anticarnist.de/tom/elternbeirat` is **lowercase** — > container registries require that in the path, even though the user (`Tom`) and > the repo (`Elternbeirat`) are capitalized. -### Logging Unraid in to the registry once +`scripts/release.sh` still builds and pushes by hand from `main`, as a fallback +when the runner is down. It does not deploy. -The image is **private**, so Unraid has to log in once before it can pull. The -**Compose Manager Plus** plugin has no UI field for this — the login runs through -the Unraid terminal (`>_` symbol at the top right of the web interface, prompt -`root@Cube:~#`): +### One-time switch from the Compose Manager -```bash -docker login gitea.anticarnist.de -# Username: Tom -# Password: -``` +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: -The login stays stored; it only has to be repeated when the token changes. Two -pitfalls learned from experience: +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. -- **Don't confuse it with PowerShell/laptop.** The login has to happen in the - *Unraid* terminal (`root@Cube`), not in Windows PowerShell (`PS C:\`). The laptop - needs the login only to *push*, Unraid to *pull*. -- **A wrong username gets stuck.** If the login reports "Stored credentials - invalid or expired" and does *not* ask for the name, first `docker logout - gitea.anticarnist.de`, then log in again — otherwise a nonsense username gets - stored by accident. -- **Plain-text warning.** Docker stores the token unencrypted in - `/root/.docker/config.json`. On your own server, okay for a start. - *Cleaner later:* set up a credential helper (→ open item below). - -### Pull and start again on Unraid - -In the **Compose Manager Plus** plugin (Unraid web interface): - -- **Docker** tab → **Compose** section → stack **eb-stack** → - **Compose Down**, then **Compose Up** (or "Pull" + "Up", depending on the plugin - version), so that the new `:latest` is pulled. Only the `eb-blazor` image - changes on a deploy; `eb-pocketbase` and its `pb_data` volume stay as they are. - -> `docker compose up` does **not** automatically re-pull a `:latest` if an image of -> the same name is already present locally. When in doubt, explicitly "Pull" first. +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 and is the file Unraid uses. It defines -both services with no host port mappings — in production NPM is the only path to -the web app, and the editors reach PocketBase through an NPM subdomain (see #9). +`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` still publishes +`8090` for the editors until they reach it through an NPM subdomain (see #9). `eb-pocketbase` keeps its data on the bind mount `/mnt/user/appdata/pocketbase/pb_data`, which only exists on the server. 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`. -> **NPM network (still open).** The base does not yet attach `eb-blazor` to the -> external NPM Docker network; while the domain has not moved, add a temporary -> `ports:` mapping (e.g. `5000:8080`) to reach the app on the LAN, and swap it for -> the `npm` external network once NPM sits in front. Tracked with #9. - --- ## Outage: PocketBase unreachable @@ -155,10 +201,9 @@ web app is needed — the site comes back by itself. ## Rollback -`scripts/release.sh` additionally tags each release with the short commit SHA, -which — unlike the moving `:latest` — never shifts. To roll back, replace -`:latest` in the Unraid `compose.yaml` with the `:` of the last working state -and bring it back up: +Every image is also tagged with the short commit SHA, which — unlike the moving +`:latest` — never shifts. To roll back, pin that SHA in `compose.yaml` on a branch, +merge it and let the workflow deploy it: ```yaml image: gitea.anticarnist.de/tom/elternbeirat:99dd052 # instead of :latest @@ -171,25 +216,23 @@ Which SHA tags are in the registry is shown by Gitea under ## Automation -### Build and push (done) +### Build and deploy (done) -`.gitea/workflows/deploy.yml` builds the image on every push to `main` and pushes -it to the registry, tagged `:latest` **and** `:` — the same scheme as -`scripts/release.sh`, just run by the `act_runner` instead of by hand. It does -**not** deploy; pulling and starting the new `:latest` on Unraid stays a manual, -deliberate step (see "Pull and start again on Unraid" above). +`.gitea/workflows/deploy.yml` has two jobs: `build` (image → registry) and +`deploy` (compose up on Unraid + health gate). The `deploy` job works because the +`act_runner` runs on Unraid and passes its Docker socket into the job, so every +`docker` command there talks to the Unraid daemon. -Requires two repository secrets (Gitea → repo → **Settings** → **Actions** → +Requires three repository secrets (Gitea → repo → **Settings** → **Actions** → **Secrets**): - `REGISTRY_USER` — the registry username (e.g. `Tom`). - `REGISTRY_TOKEN` — a Gitea access token with **`package: write`**, *not* the login password. +- `STRATO_DYNDNS_PASSWORD` — the DynDNS password for `eb-ddns` (see above). -The workflow currently only builds and pushes — it does **not** run the tests -yet, and it does **not** deploy. Those open steps (tests in the workflow, -auto-deploy with a health gate via Watchtower, encrypting the registry token on -Unraid) are tracked as Gitea issues under the "Elternbeirat-Website" milestone. +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: diff --git a/docs/unraid-infrastructure.md b/docs/unraid-infrastructure.md new file mode 100644 index 0000000..e1b7f85 --- /dev/null +++ b/docs/unraid-infrastructure.md @@ -0,0 +1,89 @@ +# 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` | `8090` | `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, 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 | +| `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` |