- eb-blazor joins the external network proxynet and publishes no host port; NPM forwards to eb-blazor:8080 by name - Stack network gets the fixed name eb-internal (Compose Manager derives the project name from the stack folder); the dev overlay resets it and turns proxynet into a local network - eb-ddns keeps the A record of elternbeirat-igmh.info at Strato current - docs/unraid-infrastructure.md records the actual Unraid state Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
267 lines
11 KiB
Markdown
267 lines
11 KiB
Markdown
# 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.
|
|
|
|
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
|
|
> own machine and for how the tests run, see `entwicklung.md`. This document is
|
|
> only about getting a built image onto Unraid.
|
|
|
|
---
|
|
|
|
## Prerequisites (one-time)
|
|
|
|
### Gitea registry token
|
|
|
|
The push to the registry needs a Gitea access token with **package write
|
|
permission** (`package: Read and Write`) — **not** the account password.
|
|
|
|
1. Gitea → top right profile picture → **Settings** → **Applications**.
|
|
2. **Manage Access Tokens** section: assign a name (e.g. `registry-push`).
|
|
3. Under **Select scopes**: set `package` to **Read and Write**.
|
|
4. Click **Generate Token**, **copy the string immediately** (shown only once).
|
|
|
|
> **The token is a secret.** Never store it in plain text in Git, chats,
|
|
> screenshots, or tickets. If one does become visible: **delete** it in Gitea and
|
|
> 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.
|
|
|
|
### 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. **Compose Manager Plus** → stack **eb-stack** → env file: add
|
|
|
|
```ini
|
|
STRATO_DYNDNS_PASSWORD=<DynDNS password>
|
|
```
|
|
|
|
**No quotes** — Compose Manager Plus passed them on as part of the password,
|
|
which Strato answered with `badauth`. The password ends up inside JSON, so it
|
|
must not contain `"` or `\`; avoid `$` and `#` as well.
|
|
4. **Compose Down**, then **Compose Up** (a plain restart keeps the old env).
|
|
`docker logs eb-ddns` shows `Updating record … to use <IP>` 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=<current IP>"
|
|
```
|
|
|
|
> **The DynDNS password is a secret** like the registry token: only in the stack's
|
|
> env on the server, 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
|
|
|
|
`main` is the **published** state — only `:latest` is built from it, and only
|
|
`:latest` is pulled by Unraid. That is why we never commit directly to `main`:
|
|
|
|
1. Create a feature branch: `git switch -c <area>/<short>` (e.g.
|
|
`deployment/sha-tagging`, `content/pipeline`).
|
|
2. Commit there, push the branch: `git push -u origin <branch>`.
|
|
3. Open a **Pull Request** against `main` in Gitea and merge it there.
|
|
4. Only then build the release image from `main` (below).
|
|
|
|
**Dev builds stay local.** For trying things out on your own machine, run the
|
|
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)
|
|
|
|
Prerequisite: logged in to the registry once (see below). Then, **on main** and
|
|
with a clean working directory:
|
|
|
|
```bash
|
|
scripts/release.sh
|
|
```
|
|
|
|
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.
|
|
|
|
> 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
|
|
|
|
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:~#`):
|
|
|
|
```bash
|
|
docker login gitea.anticarnist.de
|
|
# Username: Tom
|
|
# Password: <package token>
|
|
```
|
|
|
|
The login stays stored; it only has to be repeated when the token changes. Two
|
|
pitfalls learned from experience:
|
|
|
|
- **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.
|
|
|
|
---
|
|
|
|
## The compose files
|
|
|
|
`compose.yaml` is the **production** base and is the file Unraid uses. 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`.
|
|
|
|
---
|
|
|
|
## Outage: PocketBase unreachable
|
|
|
|
If `eb-pocketbase` is down while `eb-blazor` runs, the app does not render
|
|
half-empty pages (the menu comes from PocketBase too). A gate in `Program.cs`
|
|
answers every **page** request with the static `wwwroot/maintenance.html`:
|
|
|
|
| Request | Answer while PocketBase is down |
|
|
|---|---|
|
|
| Any page (`/`, `/board`, `/posts/…`, unknown slugs) | **503**, `Retry-After: 60`, maintenance page |
|
|
| `/health` | **503** `PocketBase unreachable` (for Uptime Kuma) |
|
|
| `/events.ics` | 200 with an empty calendar, so subscriptions keep working |
|
|
| `/events/{id}.ics` | 503 |
|
|
| Static files (CSS, fonts, PDFs, `/maintenance.html`) | served as usual |
|
|
|
|
The gate caches the health check for **10 seconds** (`PocketBaseHealthCache`). So
|
|
after PocketBase stops, pages can render for up to 10 s more (the components
|
|
degrade on their own in that window: empty menu, a short note, 503), and after it
|
|
starts again the maintenance page can stay up for up to 10 s. No restart of the
|
|
web app is needed — the site comes back by itself.
|
|
|
|
`maintenance.html` carries its styles inline, as a copy of the tokens from
|
|
`app.css`. When colours change there, copy them over.
|
|
|
|
---
|
|
|
|
## 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 `:<sha>` of the last working state
|
|
and bring it back up:
|
|
|
|
```yaml
|
|
image: gitea.anticarnist.de/tom/elternbeirat:99dd052 # instead of :latest
|
|
```
|
|
|
|
Which SHA tags are in the registry is shown by Gitea under
|
|
`Tom/-/packages` → `elternbeirat`.
|
|
|
|
---
|
|
|
|
## Automation
|
|
|
|
### Build and push (done)
|
|
|
|
`.gitea/workflows/deploy.yml` builds the image on every push to `main` and pushes
|
|
it to the registry, tagged `:latest` **and** `:<short-sha>` — 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).
|
|
|
|
Requires two 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.
|
|
|
|
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.
|
|
|
|
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`.
|