Panel-friendly deploy: compose at the root, settings via env vars #3
11 changed files with 191 additions and 152 deletions
29
.env.example
29
.env.example
|
|
@ -1,24 +1,19 @@
|
|||
# Copy to .env (repo root, next to compose.yaml) and `chmod 600 .env`.
|
||||
# Never commit .env.
|
||||
# Optional settings for a standalone deploy (podman compose without the
|
||||
# panel). Copy to .env next to compose.yaml and `chmod 600 .env`. Never
|
||||
# commit .env. With the panel, set these in the app's Environment tab instead.
|
||||
# Everything has a working default; see compose.yaml for what each one does.
|
||||
|
||||
# Required: public hostname, with a DNS A/AAAA record pointing at this server.
|
||||
# Standalone HTTPS: public hostname with a DNS record pointing here.
|
||||
DOMAIN=oweme.example.com
|
||||
|
||||
# Web Push. Generate the keys with:
|
||||
# podman run --rm --user root -v ./.env:/out/.env:Z localhost/oweme:latest node server/gen-vapid.ts /out/.env
|
||||
# (or, with Node 24 installed: node apps/server/src/gen-vapid.ts .env)
|
||||
# Leave empty to disable notifications.
|
||||
VAPID_SUBJECT=mailto:you@example.com
|
||||
VAPID_PUBLIC_KEY=
|
||||
VAPID_PRIVATE_KEY=
|
||||
#VAPID_SUBJECT=mailto:you@example.com
|
||||
#MAX_PHOTO_BYTES=2097152
|
||||
#MAX_EVENT_BYTES=65536
|
||||
#MAX_GROUP_BYTES=209715200
|
||||
#GROUP_CREATE_PER_HOUR=10
|
||||
#PUSH_DISABLED=0
|
||||
|
||||
# Limits (bytes). Defaults shown.
|
||||
MAX_PHOTO_BYTES=2097152
|
||||
MAX_EVENT_BYTES=65536
|
||||
MAX_GROUP_BYTES=209715200
|
||||
GROUP_CREATE_PER_HOUR=10
|
||||
|
||||
# Where Caddy listens. Defaults: all interfaces, ports 80/443.
|
||||
# Where the standalone Caddy listens. Defaults: all interfaces, ports 80/443.
|
||||
#BIND_ADDR=0.0.0.0
|
||||
#HTTP_PORT=80
|
||||
#HTTPS_PORT=443
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ End-to-end encrypted group expense splitter (a Settle Up clone). Read
|
|||
that way unless there's a strong reason.
|
||||
- `apps/web/` — Svelte 5 SPA + service worker (`src/sw.ts`, built separately
|
||||
by `vite.sw.config.ts` as a classic script).
|
||||
- `compose.yaml` + `.env.example` (repo root) — the podman compose deployment.
|
||||
- `compose.yaml` (repo root) — the deployment; the panel needs it at the root.
|
||||
Settings are `${VAR:-default}` there; push keys are generated into the volume.
|
||||
Caddy is only in the `standalone` profile (the panel brings its own).
|
||||
- `deploy/` — Containerfile, Caddyfile, deploy docs.
|
||||
- `e2e/` — Playwright tests against the production build.
|
||||
|
||||
|
|
@ -57,4 +59,4 @@ notifications.
|
|||
Push payloads carry only the group id.
|
||||
7. Strict CSP: no inline scripts, no third-party origins.
|
||||
8. Containers: rootless Podman; for local testing publish to `127.0.0.1` only
|
||||
(`BIND_ADDR=127.0.0.1` in `.env`).
|
||||
(`BIND_ADDR=127.0.0.1` in `.env` for the standalone profile).
|
||||
|
|
|
|||
59
SPEC.md
59
SPEC.md
|
|
@ -503,46 +503,33 @@ e2e/ Playwright tests
|
|||
|
||||
---
|
||||
|
||||
## 13. Deployment (VPS, podman compose)
|
||||
## 13. Deployment (podman compose, with or without the panel)
|
||||
|
||||
`compose.yaml` (repo root) runs two services:
|
||||
`compose.yaml` (repo root) runs the `app` service: the Node server, which
|
||||
also serves the built static client, on port 8080 with its data in the
|
||||
`oweme-data` volume. It works with **zero configuration**: VAPID keys are
|
||||
generated on first start and stored in the volume (`vapid.json`, mode 600),
|
||||
and the push contact defaults to `https://<site domain>`.
|
||||
|
||||
- `app`: the Node server, which also serves the built static client. Listens
|
||||
on the internal network only.
|
||||
- `caddy`: TLS termination + reverse proxy, the only service publishing
|
||||
ports (80/443).
|
||||
Every setting is an optional environment variable, written in `compose.yaml`
|
||||
as `${VAR:-default}` so it is visible and documented in one place:
|
||||
`MAX_PHOTO_BYTES`, `MAX_EVENT_BYTES`, `MAX_GROUP_BYTES`,
|
||||
`GROUP_CREATE_PER_HOUR`, `VAPID_SUBJECT`, `VAPID_PUBLIC_KEY` /
|
||||
`VAPID_PRIVATE_KEY` (pin keys), `PUSH_DISABLED`.
|
||||
|
||||
Volumes: `oweme-data` (SQLite + blobs), `caddy-data` (certificates).
|
||||
- **With the panel** (the main target): the panel clones the repo, finds
|
||||
`compose.yaml` at the root, routes the app's domain to `app:8080` through
|
||||
its own Caddy (HTTPS) and passes the Environment tab's variables to
|
||||
compose for `${VAR}` interpolation. "Pass to every container" must stay
|
||||
off until the panel's injection override stops clashing with variables the
|
||||
compose file sets (podman-compose: `can't merge value of [KEY]`).
|
||||
- **Standalone**: `podman compose --profile standalone up -d` adds a Caddy
|
||||
container with automatic HTTPS for `DOMAIN`, published on
|
||||
`${BIND_ADDR}:${HTTP_PORT}/${HTTPS_PORT}` (defaults all interfaces, 80/443).
|
||||
Settings come from `.env` next to `compose.yaml`.
|
||||
|
||||
Deploy steps (documented in `deploy/README.md`):
|
||||
|
||||
1. Point a DNS A/AAAA record at the VPS.
|
||||
2. `cp .env.example .env && chmod 600 .env`, then set
|
||||
`DOMAIN` (e.g. `oweme.example.com`); Caddy uses it for the site address
|
||||
and certificate. (The app itself needs no domain: share links use the
|
||||
page's own origin and the CSP is `'self'`.) Generate VAPID keys with
|
||||
`gen-vapid.ts` inside the built image, which writes them into `.env`
|
||||
without printing them.
|
||||
3. Rootless Podman cannot bind ports < 1024 by default: either set
|
||||
`net.ipv4.ip_unprivileged_port_start=80` via sysctl, or publish 8080/8443 and
|
||||
redirect with the firewall — both documented.
|
||||
4. `podman compose up -d` from the repo root. Updates: `git pull && podman compose up -d --build`.
|
||||
5. Backups: copy the data volume. All contents are already encrypted, so
|
||||
backups can be stored anywhere.
|
||||
|
||||
Environment variables (`.env`, read by `compose.yaml`):
|
||||
|
||||
| Variable | Required | Default | Purpose |
|
||||
|---|---|---|---|
|
||||
| `DOMAIN` | yes | — | Public hostname; Caddy site + TLS, share links |
|
||||
| `VAPID_PUBLIC_KEY` / `VAPID_PRIVATE_KEY` | for push | — | Web Push (generated by script); empty = notifications off |
|
||||
| `VAPID_SUBJECT` | for push | — | `mailto:` contact for push services |
|
||||
| `MAX_PHOTO_BYTES` | no | `2097152` | Per-photo upload cap |
|
||||
| `MAX_EVENT_BYTES` | no | `65536` | Per-event cap |
|
||||
| `MAX_GROUP_BYTES` | no | `209715200` | Per-group storage cap |
|
||||
| `GROUP_CREATE_PER_HOUR` | no | `10` | Group creations per 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 |
|
||||
Step-by-step instructions, the full settings table, ports for rootless Podman
|
||||
and backups are in `deploy/README.md`.
|
||||
|
||||
Development (on the dev box): servers bind `127.0.0.1` only; preview over an
|
||||
SSH tunnel. Ports and commands go in `AGENTS.md`.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import type { IncomingMessage, ServerResponse } from 'node:http';
|
|||
import { extname, join, normalize, sep } from 'node:path';
|
||||
import type { Config } from './config.ts';
|
||||
import type { Store } from './db.ts';
|
||||
import { isAllowedEndpoint, sendPush, type Vapid } from './push.ts';
|
||||
import { isAllowedEndpoint, loadVapidKeys, sendPush, type Vapid } from './push.ts';
|
||||
|
||||
const ID_RE = /^[A-Za-z0-9_-]{22}$/; // 16 random bytes, base64url
|
||||
const EVENT_ID_RE = /^[A-Za-z0-9_-]{8,100}$/;
|
||||
|
|
@ -114,10 +114,9 @@ export function createApp(cfg: Config, store: Store) {
|
|||
const streams = new Map<string, Set<ServerResponse>>();
|
||||
const createLimiter = new RateLimiter(cfg.groupCreatePerHour, 3600_000);
|
||||
const pushLimiter = new RateLimiter(60, 3600_000);
|
||||
const vapid: Vapid | null =
|
||||
cfg.vapidPublicKey && cfg.vapidPrivateKey && cfg.vapidSubject
|
||||
? { publicKey: cfg.vapidPublicKey, privateKey: cfg.vapidPrivateKey, subject: cfg.vapidSubject }
|
||||
: null;
|
||||
const keys = cfg.pushEnabled ? loadVapidKeys(cfg.dataDir, cfg.vapidPublicKey, cfg.vapidPrivateKey) : null;
|
||||
if (keys) console.log(`push: VAPID keys from ${keys.source}`);
|
||||
const vapid: Vapid | null = keys ? { publicKey: keys.publicKey, privateKey: keys.privateKey, subject: cfg.vapidSubject } : null;
|
||||
const blobDir = (g: string) => join(cfg.dataDir, 'blobs', g);
|
||||
|
||||
function clientIp(req: IncomingMessage): string {
|
||||
|
|
@ -141,9 +140,18 @@ export function createApp(cfg: Config, store: Store) {
|
|||
return g;
|
||||
}
|
||||
|
||||
// Push services want a contact URL in the VAPID token. Without
|
||||
// VAPID_SUBJECT, use the public site address the requests arrive on.
|
||||
function rememberOrigin(req: IncomingMessage) {
|
||||
if (!vapid || cfg.vapidSubject) return;
|
||||
const fwd = cfg.trustProxy ? req.headers['x-forwarded-host'] : undefined;
|
||||
const host = String(fwd ?? req.headers.host ?? '').split(',')[0].trim().toLowerCase();
|
||||
if (/^[a-z0-9.-]+\.[a-z]{2,}(:\d+)?$/.test(host) && !host.startsWith('localhost')) vapid.subject = `https://${host}`;
|
||||
}
|
||||
|
||||
function notify(groupId: string, seq: number, deviceId: string): void {
|
||||
for (const res of streams.get(groupId) ?? []) res.write(`data: ${seq}\n\n`);
|
||||
if (!vapid) return;
|
||||
if (!vapid?.subject) return;
|
||||
for (const sub of store.pushSubs(groupId)) {
|
||||
if (sub.deviceId === deviceId) continue;
|
||||
void sendPush(sub, { g: groupId }, vapid).then((r) => {
|
||||
|
|
@ -336,6 +344,7 @@ export function createApp(cfg: Config, store: Store) {
|
|||
return send(res, 200, { vapidPublicKey: vapid?.publicKey ?? null, maxPhotoBytes: cfg.maxPhotoBytes, maxGroupBytes: cfg.maxGroupBytes });
|
||||
if (p === '/api/rates' && m === 'GET') return rates(res, url);
|
||||
if (p === '/api/groups' && m === 'POST') return createGroup(req, res);
|
||||
rememberOrigin(req);
|
||||
|
||||
const g = /^\/api\/groups\/([^/]+)(\/.*)?$/.exec(p);
|
||||
if (g) {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ export interface Config {
|
|||
vapidPublicKey: string;
|
||||
vapidPrivateKey: string;
|
||||
vapidSubject: string;
|
||||
pushEnabled: boolean;
|
||||
ratesEnabled: boolean;
|
||||
ratesBaseUrl: string;
|
||||
}
|
||||
|
|
@ -41,6 +42,7 @@ export function loadConfig(env = process.env): Config {
|
|||
vapidPublicKey: env.VAPID_PUBLIC_KEY || '',
|
||||
vapidPrivateKey: env.VAPID_PRIVATE_KEY || '',
|
||||
vapidSubject: env.VAPID_SUBJECT || '',
|
||||
pushEnabled: env.PUSH_DISABLED !== '1',
|
||||
ratesEnabled: env.RATES_DISABLED !== '1',
|
||||
ratesBaseUrl: env.RATES_BASE_URL || 'https://www.ecb.europa.eu/stats/eurofxref',
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
// Generate VAPID keys and write them into an env file without printing the
|
||||
// private key: `node apps/server/src/gen-vapid.ts .env`.
|
||||
// Existing VAPID_PUBLIC_KEY / VAPID_PRIVATE_KEY lines are kept unless
|
||||
// --force is given (rotating keys invalidates every push subscription).
|
||||
import { chmodSync, existsSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import { generateVapidKeys } from './push.ts';
|
||||
|
||||
const file = process.argv[2];
|
||||
const force = process.argv.includes('--force');
|
||||
if (!file) {
|
||||
console.error('usage: node gen-vapid.ts <env-file> [--force]');
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const lines = existsSync(file) ? readFileSync(file, 'utf8').split('\n') : [];
|
||||
const has = (k: string) => lines.some((l) => l.startsWith(`${k}=`) && l.length > k.length + 1);
|
||||
if (has('VAPID_PUBLIC_KEY') && has('VAPID_PRIVATE_KEY') && !force) {
|
||||
console.error(`${file} already has VAPID keys; leaving them alone (use --force to rotate).`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const { publicKey, privateKey } = generateVapidKeys();
|
||||
const kept = lines.filter((l) => !l.startsWith('VAPID_PUBLIC_KEY=') && !l.startsWith('VAPID_PRIVATE_KEY='));
|
||||
while (kept.length && kept[kept.length - 1] === '') kept.pop();
|
||||
kept.push(`VAPID_PUBLIC_KEY=${publicKey}`, `VAPID_PRIVATE_KEY=${privateKey}`, '');
|
||||
writeFileSync(file, kept.join('\n'), { mode: 0o600 });
|
||||
chmodSync(file, 0o600);
|
||||
console.error(`Wrote VAPID keys to ${file} (private key ${privateKey.length} chars, not shown).`);
|
||||
|
|
@ -16,7 +16,7 @@ if (cfg.ratesEnabled) rates.start();
|
|||
|
||||
server.listen(cfg.port, cfg.host, () => {
|
||||
console.log(`oweme server on http://${cfg.host}:${cfg.port}` + (cfg.staticDir ? ` serving ${cfg.staticDir}` : ' (API only)'));
|
||||
if (!cfg.vapidPublicKey) console.log('push notifications disabled: VAPID_* not set');
|
||||
if (!cfg.pushEnabled) console.log('push notifications disabled (PUSH_DISABLED=1)');
|
||||
});
|
||||
|
||||
for (const sig of ['SIGINT', 'SIGTERM'] as const) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
// the service worker fetches and decrypts the actual events itself, so the
|
||||
// push service never sees content (SPEC.md §7.7).
|
||||
import { createCipheriv, createECDH, createPrivateKey, hkdfSync, randomBytes, sign } from 'node:crypto';
|
||||
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import type { PushSub } from './db.ts';
|
||||
|
||||
const b64u = (b: Buffer | Uint8Array) => Buffer.from(b).toString('base64url');
|
||||
|
|
@ -35,6 +37,23 @@ export function generateVapidKeys(): { publicKey: string; privateKey: string } {
|
|||
return { publicKey: b64u(ecdh.getPublicKey()), privateKey: b64u(ecdh.getPrivateKey()) };
|
||||
}
|
||||
|
||||
/**
|
||||
* VAPID keys from the environment if both are set, otherwise generated once
|
||||
* and kept in the data directory, so push works without any configuration.
|
||||
* Deleting vapid.json rotates them (and invalidates every subscription).
|
||||
*/
|
||||
export function loadVapidKeys(dataDir: string, envPublic: string, envPrivate: string): { publicKey: string; privateKey: string; source: string } {
|
||||
if (envPublic && envPrivate) return { publicKey: envPublic, privateKey: envPrivate, source: 'environment' };
|
||||
const file = join(dataDir, 'vapid.json');
|
||||
if (existsSync(file)) {
|
||||
const k = JSON.parse(readFileSync(file, 'utf8'));
|
||||
if (typeof k.publicKey === 'string' && typeof k.privateKey === 'string') return { ...k, source: file };
|
||||
}
|
||||
const k = generateVapidKeys();
|
||||
writeFileSync(file, JSON.stringify(k), { mode: 0o600, flag: 'wx' });
|
||||
return { ...k, source: `${file} (new)` };
|
||||
}
|
||||
|
||||
export interface Vapid {
|
||||
publicKey: string;
|
||||
privateKey: string;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { after, before, describe, it } from 'node:test';
|
|||
import { createApp } from '../src/app.ts';
|
||||
import { loadConfig } from '../src/config.ts';
|
||||
import { Store } from '../src/db.ts';
|
||||
import { encryptPayload, isAllowedEndpoint } from '../src/push.ts';
|
||||
import { encryptPayload, isAllowedEndpoint, loadVapidKeys } from '../src/push.ts';
|
||||
import { parseEcbXml } from '../src/rates.ts';
|
||||
|
||||
const b64u = (b: Buffer) => b.toString('base64url');
|
||||
|
|
@ -161,6 +161,23 @@ describe('rates and static', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('vapid keys', () => {
|
||||
it('generates keys once and keeps them in the data dir', () => {
|
||||
const d = mkdtempSync(join(tmpdir(), 'oweme-vapid-'));
|
||||
const a = loadVapidKeys(d, '', '');
|
||||
const b = loadVapidKeys(d, '', '');
|
||||
assert.equal(a.publicKey, b.publicKey);
|
||||
assert.match(a.publicKey, /^[A-Za-z0-9_-]{87}$/);
|
||||
assert.equal(loadVapidKeys(d, 'pub', 'priv').publicKey, 'pub'); // env wins
|
||||
rmSync(d, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it('exposes the public key without any configuration', async () => {
|
||||
const r = await api('GET', '/api/config');
|
||||
assert.match(r.data.vapidPublicKey, /^[A-Za-z0-9_-]{87}$/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('web push encryption', () => {
|
||||
it('produces an RFC 8291 payload the browser side can decrypt', () => {
|
||||
// Play the browser: generate a subscription key pair and auth secret.
|
||||
|
|
|
|||
42
compose.yaml
42
compose.yaml
|
|
@ -1,5 +1,12 @@
|
|||
# podman compose up -d --build (run from the repo root; reads ./.env)
|
||||
# See deploy/README.md for the full deploy steps.
|
||||
# OweMe. Works as-is with zero configuration; every setting below can be
|
||||
# overridden with an environment variable (in the panel's Environment tab,
|
||||
# or in a .env file next to this file).
|
||||
#
|
||||
# With the panel: point the app's domain at service `app`, port 8080.
|
||||
# The panel's Caddy provides HTTPS.
|
||||
# Standalone (no panel): set DOMAIN and run
|
||||
# podman compose --profile standalone up -d --build
|
||||
# which adds a Caddy container with automatic HTTPS. See deploy/README.md.
|
||||
name: oweme
|
||||
|
||||
services:
|
||||
|
|
@ -9,9 +16,25 @@ services:
|
|||
dockerfile: deploy/Containerfile
|
||||
image: localhost/oweme:latest
|
||||
restart: unless-stopped
|
||||
env_file: .env
|
||||
environment:
|
||||
# fixed inside the container; everything else comes from .env
|
||||
# Max size of one uploaded (encrypted) photo, in bytes. Default 2 MB.
|
||||
MAX_PHOTO_BYTES: ${MAX_PHOTO_BYTES:-2097152}
|
||||
# Max size of one encrypted event, in bytes. Default 64 KB.
|
||||
MAX_EVENT_BYTES: ${MAX_EVENT_BYTES:-65536}
|
||||
# Storage cap per group (events + photos), in bytes. Default 200 MB.
|
||||
MAX_GROUP_BYTES: ${MAX_GROUP_BYTES:-209715200}
|
||||
# New groups per client IP per hour.
|
||||
GROUP_CREATE_PER_HOUR: ${GROUP_CREATE_PER_HOUR:-10}
|
||||
# Contact sent to push services, e.g. mailto:you@example.com.
|
||||
# Empty = https://<the site's domain>.
|
||||
VAPID_SUBJECT: ${VAPID_SUBJECT:-}
|
||||
# Push keys. Empty = generated on first start and kept in the data
|
||||
# volume (recommended). Set both only to pin specific keys.
|
||||
VAPID_PUBLIC_KEY: ${VAPID_PUBLIC_KEY:-}
|
||||
VAPID_PRIVATE_KEY: ${VAPID_PRIVATE_KEY:-}
|
||||
# 1 = turn push notifications off.
|
||||
PUSH_DISABLED: ${PUSH_DISABLED:-0}
|
||||
# Fixed for the container; no need to change these.
|
||||
HOST: 0.0.0.0
|
||||
PORT: "8080"
|
||||
DATA_DIR: /data
|
||||
|
|
@ -23,18 +46,21 @@ services:
|
|||
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8080/api/health"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
# no published ports: only Caddy can reach the app
|
||||
# No ports: the panel publishes 8080 for its routes; standalone, only
|
||||
# Caddy reaches the app.
|
||||
|
||||
caddy:
|
||||
profiles: [standalone]
|
||||
image: docker.io/library/caddy:2.10.2-alpine
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- app
|
||||
environment:
|
||||
DOMAIN: ${DOMAIN:?set DOMAIN in .env}
|
||||
# Public hostname for standalone HTTPS (needs a DNS record).
|
||||
DOMAIN: ${DOMAIN:-localhost}
|
||||
ports:
|
||||
# BIND_ADDR defaults to all interfaces (a public VPS). Rootless Podman
|
||||
# can't bind ports below 1024 by default; see README "Ports".
|
||||
# Rootless Podman can't bind ports below 1024 by default; see
|
||||
# deploy/README.md "Ports".
|
||||
- "${BIND_ADDR:-0.0.0.0}:${HTTP_PORT:-80}:80"
|
||||
- "${BIND_ADDR:-0.0.0.0}:${HTTPS_PORT:-443}:443"
|
||||
- "${BIND_ADDR:-0.0.0.0}:${HTTPS_PORT:-443}:443/udp"
|
||||
|
|
|
|||
116
deploy/README.md
116
deploy/README.md
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue