Make the deploy panel-friendly: zero-config compose, env vars with defaults

- compose.yaml runs only the app by default; Caddy moved to the
  'standalone' profile (the panel brings its own Caddy and routes).
- No env_file: every setting is ${VAR:-default} in compose.yaml, so it
  can be set from the panel's Environment tab (or .env standalone).
- VAPID keys are generated on first start and kept in the data volume;
  the push subject defaults to https://<site domain>. gen-vapid.ts removed.
- PUSH_DISABLED=1 turns push off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013FYo6JSV1fDU1fm3LU77iF
This commit is contained in:
agent 2026-10-09 22:24:22 +00:00
parent 1382e53359
commit 04d952872d
11 changed files with 191 additions and 152 deletions

View file

@ -1,60 +1,48 @@
# Deploying OweMe on a VPS
# Deploying OweMe
Two containers via `podman compose`: **app** (the Node server plus the built
web client) and **caddy** (HTTPS and reverse proxy). Only Caddy publishes ports.
`compose.yaml` (repo root) runs the **app** container: the Node server plus
the built web client, listening on port 8080, with its data in the
`oweme-data` volume. It needs **no configuration**: push keys are generated
on first start and kept in the volume. Every setting is an optional
environment variable, listed with its default in `compose.yaml`.
## Requirements
HTTPS comes either from the panel's Caddy or, standalone, from a Caddy
container enabled with the `standalone` profile.
- Podman ≥ 4 with `podman compose` (podman-compose or docker-compose as the provider)
- A domain with an A/AAAA record pointing at the VPS
- Ports 80 and 443 (TCP, plus UDP 443 for HTTP/3) open in the firewall
## With the panel
## First deploy
1. **New app → Git repository**: this repo, branch `main`. The panel finds
`compose.yaml` in the repository root.
2. **Domain**: point it at service **`app`**, port **`8080`**. The panel
publishes the port on 127.0.0.1 and its Caddy serves HTTPS.
3. **Environment** (optional): any variable from `compose.yaml`, for example
`MAX_PHOTO_BYTES=5242880` or `VAPID_SUBJECT=mailto:you@example.com`.
Untick **Pass to every container**. `compose.yaml` already passes each
setting to the app, and the panel's per-container copy currently makes
podman-compose fail with `can't merge value of [KEY] …` for variables the
compose file also sets.
4. **Deploy.** Check `https://<domain>/api/health` → `{"ok":true}`.
Changing a variable takes effect on the next deploy. Volume backups in the
panel include the `oweme-data` volume (database, encrypted photos, push keys).
## Standalone (no panel)
Requirements: Podman ≥ 4 with podman-compose ≥ 1.1 (for profiles), a domain
with an A/AAAA record pointing at the server, and ports 80 and 443 (TCP, plus
UDP 443 for HTTP/3) open.
```sh
git clone <repo> oweme && cd oweme
cp .env.example .env
chmod 600 .env
$EDITOR .env # set DOMAIN and VAPID_SUBJECT (mailto:)
podman compose build # builds localhost/oweme:latest
# Web Push keys: written into .env, private key never printed.
podman run --rm --user root -v ./.env:/out/.env:Z localhost/oweme:latest node server/gen-vapid.ts /out/.env
podman compose up -d
podman compose logs -f # Caddy obtains the certificate on first request
cp .env.example .env && chmod 600 .env
$EDITOR .env # set DOMAIN
podman compose --profile standalone up -d --build
podman compose logs -f # Caddy gets the certificate on the first request
```
Open `https://$DOMAIN`. `curl https://$DOMAIN/api/health` should say `{"ok":true}`.
Updating: `git pull && podman compose --profile standalone up -d --build`.
## Updating
```sh
cd oweme && git pull
podman compose up -d --build
```
Data lives in the `oweme-data` volume and survives rebuilds.
## Configuration (`.env`)
| Variable | Required | Default | Purpose |
|---|---|---|---|
| `DOMAIN` | yes | — | Public hostname; Caddy's site address and certificate |
| `VAPID_SUBJECT` | for push | — | `mailto:` contact sent to push services |
| `VAPID_PUBLIC_KEY` / `VAPID_PRIVATE_KEY` | for push | — | Generated by `gen-vapid.ts`; empty = notifications off |
| `MAX_PHOTO_BYTES` | no | `2097152` | Max size of one uploaded (encrypted) photo |
| `MAX_EVENT_BYTES` | no | `65536` | Max size of one encrypted event |
| `MAX_GROUP_BYTES` | no | `209715200` | Storage cap per group (events + photos) |
| `GROUP_CREATE_PER_HOUR` | no | `10` | Group creations per client IP per hour |
| `BIND_ADDR` | no | `0.0.0.0` | Address Caddy's ports are published on |
| `HTTP_PORT` / `HTTPS_PORT` | no | `80` / `443` | Host ports for Caddy |
Rotating the VAPID keys (`gen-vapid.ts … --force`) silently invalidates every
push subscription; users have to toggle notifications off and on again.
## Ports (rootless Podman)
### Ports (rootless Podman)
Rootless Podman can't bind ports below 1024 by default. Pick one:
@ -63,30 +51,52 @@ Rootless Podman can't bind ports below 1024 by default. Pick one:
echo 'net.ipv4.ip_unprivileged_port_start=80' | sudo tee /etc/sysctl.d/90-unprivileged-ports.conf
sudo sysctl --system
```
2. Or publish high ports (`HTTP_PORT=8080`, `HTTPS_PORT=8443`) and redirect
80→8080 / 443→8443 in your firewall (e.g. nftables/UFW `nat` rules).
2. Or publish high ports (`HTTP_PORT=8080`, `HTTPS_PORT=8443` in `.env`) and
redirect 80→8080 / 443→8443 in your firewall.
With rootless Podman, published ports go through `rootlessport` and are
subject to the host firewall. Rootful container networking can add its own
firewall rules around UFW, so don't rely on UFW alone if you run rootful.
## Settings
All optional. Set them in the panel's Environment tab, or in `.env` for a
standalone deploy.
| Variable | Default | Purpose |
|---|---|---|
| `MAX_PHOTO_BYTES` | `2097152` | Max size of one uploaded (encrypted) photo |
| `MAX_EVENT_BYTES` | `65536` | Max size of one encrypted event |
| `MAX_GROUP_BYTES` | `209715200` | Storage cap per group (events + photos) |
| `GROUP_CREATE_PER_HOUR` | `10` | Group creations per client IP per hour |
| `VAPID_SUBJECT` | `https://<site domain>` | Contact sent to push services |
| `VAPID_PUBLIC_KEY` / `VAPID_PRIVATE_KEY` | generated | Pin push keys (set both); otherwise kept in the volume as `vapid.json` |
| `PUSH_DISABLED` | `0` | `1` turns push notifications off |
| `DOMAIN` | `localhost` | Standalone only: Caddy's site address and certificate |
| `BIND_ADDR` | `0.0.0.0` | Standalone only: address Caddy's ports are published on |
| `HTTP_PORT` / `HTTPS_PORT` | `80` / `443` | Standalone only: host ports for Caddy |
Deleting `vapid.json` from the volume (or changing pinned keys) invalidates
every push subscription; people then turn notifications off and on again.
## Backups
Back up the `oweme-data` volume (SQLite database + encrypted photos):
The `oweme-data` volume holds everything (SQLite database, encrypted photos,
push keys). Its contents are end-to-end encrypted, so backups can be stored
anywhere. Standalone:
```sh
podman volume export oweme_oweme-data > oweme-data-$(date +%F).tar
```
Everything in it is already end-to-end encrypted, so the backup can be stored
anywhere. Users can also download per-group backup files in the app.
People can also download per-group backup files in the app.
## Testing a deployment
From a machine with the repo and Node 24:
```sh
npm ci && E2E_BASE_URL=https://$DOMAIN npx playwright test e2e/app.spec.ts
npm ci && E2E_BASE_URL=https://<domain> npx playwright test e2e/app.spec.ts
```
This creates a throwaway group on that server.