Deploy the stack from the repo's compose.yaml via Gitea Actions

- deploy.yml gets a deploy job after the build: pull, compose up on Unraid
  through the runner's Docker socket, then a health gate on eb-blazor /health
  from inside proxynet; docs-only pushes trigger nothing, manual runs allowed
- STRATO_DYNDNS_PASSWORD comes from a Gitea secret instead of the Compose
  Manager env file
- restart: always, because Unraid stops containers explicitly on shutdown and
  unless-stopped would leave the stack down after a reboot; the dev overlay
  turns it off
- Docs describe the automatic rollout and the one-time switch away from the
  Compose Manager stack

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TomandClaude Opus 5.5 committed 2026-10-10 00:37:42 +02:00
1 parent 4968b62f06
commit 05b1666f81
5 files changed
+152 -99

No files matched your search

+48 -74
View File
@@ -1,8 +1,9 @@
# 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 **three-container stack** (project `eb-stack`): the Blazor app
(`eb-blazor`), a PocketBase container (`eb-pocketbase`) that holds the content,
@@ -52,16 +53,11 @@ DynDNS password.
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).
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 <IP>` with no `ERROR`
after it.
5. Check: the Strato nameservers answer with the public IP of the connection
@@ -79,8 +75,8 @@ domain or password are wrong:
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
> **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.
@@ -125,67 +121,48 @@ 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** `:<short-sha>` (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: <package token>
```
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
`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).
@@ -224,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 `:<sha>` 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
@@ -240,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** `:<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).
`.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:
+11 -11
View File
@@ -10,7 +10,7 @@ What runs on the Unraid host and how the website stack fits in. This is the
| LAN IP | `192.168.1.14` |
| Web UI | `https://unraid.server:44302` |
| Version | Unraid OS 7.0.1 |
| Stack management | Compose Manager plugin, stack `elternbeirat` |
| 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.**
@@ -19,17 +19,17 @@ attached to it fails to start.
## Website stack
The stack is created in the Compose Manager under the name `elternbeirat`. Its
compose content is a copy of `compose.yaml` **without the comments**, pasted
into the stack's config in the Unraid UI.
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 project name comes from the stack folder, not from `name:`.** The
> Compose Manager starts the stack with `-p elternbeirat`, which overrides
> `name: eb-stack`. Renaming the stack in the UI does not change it. That is why
> `compose.yaml` gives the stack's network the fixed name `eb-internal` instead of
> the derived `elternbeirat_default`. Changing a network name needs **Compose Down**
> and then **Compose Up**; a plain Up fails because the existing containers still
> point at the old network.
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 |
|---|---|---|---|