Remove the admin panel's Environment tab and env-apply
.env is edited by hand again. Drops the /admin/env endpoints, EnvManager and its registry, the host-side apply.py watcher and its install script, the backend's env-apply bind mount, and the Environment tab. The deploy and maintenance workflows still serialise docker compose, now on .compose.lock in the checkout instead of env-apply/run/lock. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+10
-53
@@ -131,7 +131,7 @@ which has two jobs:
|
||||
newer, untested commit). It fetches over `ssh://git@localhost:2222`,
|
||||
hard-resets the deploy checkout, and runs
|
||||
`docker compose up -d --build --remove-orphans` under the
|
||||
`env-apply/run/lock` flock.
|
||||
`.compose.lock` flock, shared with the weekly maintenance workflow.
|
||||
|
||||
The test job keeps state on the Pi outside the deploy checkout: a bare
|
||||
repository cache at `/home/adamf/.cache/web_server-ci/` and three named
|
||||
@@ -227,7 +227,7 @@ cert, `docker compose restart nginx` is the fix. See proposal 1 in §8.
|
||||
The `cloudflared` container holds an outbound connection to Cloudflare and
|
||||
forwards requests for the site's hostnames down it to nginx. It is a
|
||||
_remotely managed_ tunnel: the only thing in this repo is the token
|
||||
(`CLOUDFLARE_TUNNEL_TOKEN`, editable from the Environment tab); hostnames and
|
||||
(`CLOUDFLARE_TUNNEL_TOKEN` in `.env`); hostnames and
|
||||
origin settings live in the dashboard.
|
||||
|
||||
**Origin: `https://www.<DOMAIN>`, the site's own name.** Cloudflare
|
||||
@@ -250,8 +250,8 @@ Setup, once:
|
||||
1. Cloudflare dashboard → the domain must be on Cloudflare DNS.
|
||||
2. Zero Trust → Networks → Tunnels → Create a tunnel → Cloudflared. Copy the
|
||||
token from the install command (the long string after `--token`).
|
||||
3. Put it in `.env` as `CLOUDFLARE_TUNNEL_TOKEN` (or set it from the
|
||||
Environment tab), then `docker compose up -d cloudflared`. The tunnel
|
||||
3. Put it in `.env` as `CLOUDFLARE_TUNNEL_TOKEN`, then
|
||||
`docker compose up -d cloudflared`. The tunnel
|
||||
shows as Healthy in the dashboard.
|
||||
4. Add a public hostname per name, each with service `HTTPS` and its own
|
||||
name as the URL, and no other settings:
|
||||
@@ -331,7 +331,6 @@ of deleting the directory:
|
||||
| `./certbot/www` | ACME challenge webroot | Transient by nature |
|
||||
| `./backend/token/` | **Spotify OAuth refresh token** (`spotify_token.json`) | Gitignored. Without this mount, Spotify would need re-authorising after every rebuild. |
|
||||
| `./jobs-data` | The job tracker's **capture token hash** and Graph OAuth session | Gitignored. Must be owned by uid 1000, the user the `jobs` image runs as. |
|
||||
| `./env-apply/run` | The admin panel's queued `.env` change (`request.json`) and the host's report on it (`status.json`) | Gitignored. Transient, but must be owned by the deploy user, not root — see §5. |
|
||||
| `./gitea/data` | Git repositories, LFS objects, avatars, sessions | The actual git data |
|
||||
| `./gitea/config` | Gitea's live `app.ini` | Gitignored; generated from the template on first boot and then owned by Gitea |
|
||||
| `./logs` | Backend logs | |
|
||||
@@ -366,8 +365,7 @@ makes the site's one Claude call (the rowing photo reader); the `jobs` container
|
||||
allow-list with its own database role. The backend receives `CLAUDE_API_KEY`
|
||||
through `env_file` but does not use it. A new variable for either service has
|
||||
to be added to its allow-list as well as
|
||||
`.env.example` and `backend/services/env_registry.json`; backend tests fail if
|
||||
the three disagree.
|
||||
`.env.example`.
|
||||
|
||||
**`.env` reaches the Pi via `./sync-secrets.sh`**, which syncs exactly two
|
||||
things between this checkout and `adamf@stppi.local:~/deploy/web_server`:
|
||||
@@ -379,35 +377,12 @@ An unset variable is not an error: `envsubst` renders it as an empty string,
|
||||
which for a password field means _no password_. After editing `.env`, confirm
|
||||
with `docker compose config`.
|
||||
|
||||
### Editing from the admin panel
|
||||
### Changing a value on the Pi
|
||||
|
||||
The **Environment** tab at `/admin` edits `.env` on the Pi without SSH. API
|
||||
keys, OAuth client settings, the email settings and the generated secrets are
|
||||
editable; anything that would rename a container, move a port or lock the
|
||||
backend out of Postgres is shown read-only.
|
||||
|
||||
The backend cannot write `.env` or reach Docker. It queues the change in
|
||||
`./env-apply/run/request.json`, and a systemd path unit on the host runs
|
||||
`env-apply/apply.py`, which:
|
||||
|
||||
1. rewrites `.env` atomically, keeping comments and order, with the previous
|
||||
version saved as **`.env.bak`**;
|
||||
2. runs `docker compose config -q` and restores the backup if compose rejects
|
||||
the file;
|
||||
3. recreates only the services that read the changed variables, plus the
|
||||
backend (`docker compose up -d --no-deps --force-recreate …`);
|
||||
4. writes the outcome to `status.json`, which the panel is polling.
|
||||
|
||||
Only those services are recreated because nginx, db, icecast2 and certbot load
|
||||
the whole file too; a plain `up -d` would restart Postgres for a Steam key.
|
||||
They pick the new file up at the next deploy, which is harmless.
|
||||
|
||||
**The watcher is installed once per host** — see the runbook. Without it the
|
||||
panel still queues the change and says nothing has picked it up.
|
||||
|
||||
A change made this way makes the Pi's `.env` the newer copy, so the next
|
||||
`./sync-secrets.sh` pulls it down to the laptop. The newer-wins caveat above
|
||||
still applies: do not also edit the local copy before syncing.
|
||||
Edit `.env` (on the laptop, then `./sync-secrets.sh`; or on the Pi directly,
|
||||
then sync back), and recreate only the services that read the variable:
|
||||
`docker compose up -d <service>`. A plain `up -d` would also restart Postgres,
|
||||
since nginx, db, icecast2 and certbot load the whole file.
|
||||
|
||||
---
|
||||
|
||||
@@ -456,24 +431,6 @@ it. By hand:
|
||||
git pull && docker compose up -d --build --remove-orphans
|
||||
```
|
||||
|
||||
**Install the `.env` watcher** (once per host; lets the admin panel's
|
||||
Environment tab apply changes):
|
||||
|
||||
```
|
||||
./env-apply/install.sh # asks for sudo
|
||||
systemctl status web-server-env-apply.path # should be active (waiting)
|
||||
journalctl -u web-server-env-apply.service # one entry per applied change
|
||||
```
|
||||
|
||||
Run it as the user that owns the checkout. `env-apply/run` must belong to that
|
||||
user: if Docker created it first it is root-owned, and the script fixes that.
|
||||
To apply a queued change by hand, or undo one:
|
||||
|
||||
```
|
||||
python3 env-apply/apply.py # apply what the panel queued
|
||||
cp .env.bak .env && docker compose up -d # roll back the last change
|
||||
```
|
||||
|
||||
**Rebuild one service** (e.g. after changing only the backend):
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user