oweme/deploy/README.md
agent 1382e53359 Move compose.yaml and .env.example to the repo root
Deploy is now `podman compose up -d` from the root. Add .containerignore
so node_modules, local data and .env stay out of the build context, and
mount only .env (not the whole tree) when generating VAPID keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013FYo6JSV1fDU1fm3LU77iF
2026-10-09 20:45:28 +00:00

92 lines
3.2 KiB
Markdown

# Deploying OweMe on a VPS
Two containers via `podman compose`: **app** (the Node server plus the built
web client) and **caddy** (HTTPS and reverse proxy). Only Caddy publishes ports.
## Requirements
- 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
## First deploy
```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
```
Open `https://$DOMAIN`. `curl https://$DOMAIN/api/health` should say `{"ok":true}`.
## 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)
Rootless Podman can't bind ports below 1024 by default. Pick one:
1. Allow it (simplest):
```sh
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).
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.
## Backups
Back up the `oweme-data` volume (SQLite database + encrypted photos):
```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.
## 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
```
This creates a throwaway group on that server.