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
This commit is contained in:
agent 2026-10-09 20:45:28 +00:00
parent 41b3487a5a
commit 1382e53359
9 changed files with 31 additions and 21 deletions

8
.containerignore Normal file
View file

@ -0,0 +1,8 @@
# Keep the image build context small and free of secrets/local data.
**/node_modules
**/dist
data
.env
test-results
playwright-report
.git

View file

@ -1,11 +1,12 @@
# Copy to deploy/.env and `chmod 600 deploy/.env`. Never commit .env. # Copy to .env (repo root, next to compose.yaml) and `chmod 600 .env`.
# Never commit .env.
# Required: public hostname, with a DNS A/AAAA record pointing at this server. # Required: public hostname, with a DNS A/AAAA record pointing at this server.
DOMAIN=oweme.example.com DOMAIN=oweme.example.com
# Web Push. Generate the keys with: # Web Push. Generate the keys with:
# podman run --rm --user root -v ./:/out:Z localhost/oweme:latest node server/gen-vapid.ts /out/.env # 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 deploy/.env) # (or, with Node 24 installed: node apps/server/src/gen-vapid.ts .env)
# Leave empty to disable notifications. # Leave empty to disable notifications.
VAPID_SUBJECT=mailto:you@example.com VAPID_SUBJECT=mailto:you@example.com
VAPID_PUBLIC_KEY= VAPID_PUBLIC_KEY=

1
.gitignore vendored
View file

@ -2,7 +2,6 @@ node_modules/
dist/ dist/
data/ data/
.env .env
deploy/.env
test-results/ test-results/
playwright-report/ playwright-report/
*.log *.log

View file

@ -13,7 +13,8 @@ End-to-end encrypted group expense splitter (a Settle Up clone). Read
that way unless there's a strong reason. that way unless there's a strong reason.
- `apps/web/` — Svelte 5 SPA + service worker (`src/sw.ts`, built separately - `apps/web/` — Svelte 5 SPA + service worker (`src/sw.ts`, built separately
by `vite.sw.config.ts` as a classic script). by `vite.sw.config.ts` as a classic script).
- `deploy/` — Containerfile, compose.yaml, Caddyfile, `.env.example`, deploy docs. - `compose.yaml` + `.env.example` (repo root) — the podman compose deployment.
- `deploy/` — Containerfile, Caddyfile, deploy docs.
- `e2e/` — Playwright tests against the production build. - `e2e/` — Playwright tests against the production build.
## Run ## Run
@ -56,4 +57,4 @@ notifications.
Push payloads carry only the group id. Push payloads carry only the group id.
7. Strict CSP: no inline scripts, no third-party origins. 7. Strict CSP: no inline scripts, no third-party origins.
8. Containers: rootless Podman; for local testing publish to `127.0.0.1` only 8. Containers: rootless Podman; for local testing publish to `127.0.0.1` only
(`BIND_ADDR=127.0.0.1` in `deploy/.env`). (`BIND_ADDR=127.0.0.1` in `.env`).

11
SPEC.md
View file

@ -496,7 +496,8 @@ Repo layout (monorepo):
apps/web Svelte client + service worker apps/web Svelte client + service worker
apps/server Node API (no dependencies) apps/server Node API (no dependencies)
packages/core shared: types, event schema, money math, replay, settle-up, recurring, stats, CSV packages/core shared: types, event schema, money math, replay, settle-up, recurring, stats, CSV
deploy/ Containerfile, compose.yaml, Caddyfile, .env.example, README compose.yaml podman compose deployment (with .env.example)
deploy/ Containerfile, Caddyfile, README
e2e/ Playwright tests e2e/ Playwright tests
``` ```
@ -504,7 +505,7 @@ e2e/ Playwright tests
## 13. Deployment (VPS, podman compose) ## 13. Deployment (VPS, podman compose)
`deploy/compose.yaml` runs two services: `compose.yaml` (repo root) runs two services:
- `app`: the Node server, which also serves the built static client. Listens - `app`: the Node server, which also serves the built static client. Listens
on the internal network only. on the internal network only.
@ -516,7 +517,7 @@ Volumes: `oweme-data` (SQLite + blobs), `caddy-data` (certificates).
Deploy steps (documented in `deploy/README.md`): Deploy steps (documented in `deploy/README.md`):
1. Point a DNS A/AAAA record at the VPS. 1. Point a DNS A/AAAA record at the VPS.
2. `cp deploy/.env.example deploy/.env && chmod 600 deploy/.env`, then set 2. `cp .env.example .env && chmod 600 .env`, then set
`DOMAIN` (e.g. `oweme.example.com`); Caddy uses it for the site address `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 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 page's own origin and the CSP is `'self'`.) Generate VAPID keys with
@ -525,11 +526,11 @@ Deploy steps (documented in `deploy/README.md`):
3. Rootless Podman cannot bind ports < 1024 by default: either set 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 `net.ipv4.ip_unprivileged_port_start=80` via sysctl, or publish 8080/8443 and
redirect with the firewall — both documented. redirect with the firewall — both documented.
4. `cd deploy && podman compose up -d`. Updates: `git pull && podman compose up -d --build`. 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 5. Backups: copy the data volume. All contents are already encrypted, so
backups can be stored anywhere. backups can be stored anywhere.
Environment variables (`deploy/.env`, read by `compose.yaml`): Environment variables (`.env`, read by `compose.yaml`):
| Variable | Required | Default | Purpose | | Variable | Required | Default | Purpose |
|---|---|---|---| |---|---|---|---|

View file

@ -1,4 +1,4 @@
// All configuration comes from environment variables (see deploy/.env.example). // All configuration comes from environment variables (see .env.example).
import { resolve } from 'node:path'; import { resolve } from 'node:path';
function int(env: NodeJS.ProcessEnv, name: string, def: number): number { function int(env: NodeJS.ProcessEnv, name: string, def: number): number {

View file

@ -1,5 +1,5 @@
// Generate VAPID keys and write them into an env file without printing the // Generate VAPID keys and write them into an env file without printing the
// private key: `node apps/server/src/gen-vapid.ts deploy/.env`. // private key: `node apps/server/src/gen-vapid.ts .env`.
// Existing VAPID_PUBLIC_KEY / VAPID_PRIVATE_KEY lines are kept unless // Existing VAPID_PUBLIC_KEY / VAPID_PRIVATE_KEY lines are kept unless
// --force is given (rotating keys invalidates every push subscription). // --force is given (rotating keys invalidates every push subscription).
import { chmodSync, existsSync, readFileSync, writeFileSync } from 'node:fs'; import { chmodSync, existsSync, readFileSync, writeFileSync } from 'node:fs';

View file

@ -1,11 +1,11 @@
# podman compose up -d --build (run from this directory; reads ./.env) # podman compose up -d --build (run from the repo root; reads ./.env)
# See deploy/README.md for the full deploy steps. # See deploy/README.md for the full deploy steps.
name: oweme name: oweme
services: services:
app: app:
build: build:
context: .. context: .
dockerfile: deploy/Containerfile dockerfile: deploy/Containerfile
image: localhost/oweme:latest image: localhost/oweme:latest
restart: unless-stopped restart: unless-stopped
@ -31,7 +31,7 @@ services:
depends_on: depends_on:
- app - app
environment: environment:
DOMAIN: ${DOMAIN:?set DOMAIN in deploy/.env} DOMAIN: ${DOMAIN:?set DOMAIN in .env}
ports: ports:
# BIND_ADDR defaults to all interfaces (a public VPS). Rootless Podman # BIND_ADDR defaults to all interfaces (a public VPS). Rootless Podman
# can't bind ports below 1024 by default; see README "Ports". # can't bind ports below 1024 by default; see README "Ports".
@ -39,7 +39,7 @@ services:
- "${BIND_ADDR:-0.0.0.0}:${HTTPS_PORT:-443}:443" - "${BIND_ADDR:-0.0.0.0}:${HTTPS_PORT:-443}:443"
- "${BIND_ADDR:-0.0.0.0}:${HTTPS_PORT:-443}:443/udp" - "${BIND_ADDR:-0.0.0.0}:${HTTPS_PORT:-443}:443/udp"
volumes: volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro,Z - ./deploy/Caddyfile:/etc/caddy/Caddyfile:ro,Z
- caddy-data:/data - caddy-data:/data
- caddy-config:/config - caddy-config:/config

View file

@ -12,7 +12,7 @@ web client) and **caddy** (HTTPS and reverse proxy). Only Caddy publishes ports.
## First deploy ## First deploy
```sh ```sh
git clone <repo> oweme && cd oweme/deploy git clone <repo> oweme && cd oweme
cp .env.example .env cp .env.example .env
chmod 600 .env chmod 600 .env
@ -20,7 +20,7 @@ $EDITOR .env # set DOMAIN and VAPID_SUBJECT (mailto:)
podman compose build # builds localhost/oweme:latest podman compose build # builds localhost/oweme:latest
# Web Push keys: written into .env, private key never printed. # Web Push keys: written into .env, private key never printed.
podman run --rm --user root -v ./:/out:Z localhost/oweme:latest node server/gen-vapid.ts /out/.env 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 up -d
podman compose logs -f # Caddy obtains the certificate on first request podman compose logs -f # Caddy obtains the certificate on first request
@ -32,12 +32,12 @@ Open `https://$DOMAIN`. `curl https://$DOMAIN/api/health` should say `{"ok":true
```sh ```sh
cd oweme && git pull cd oweme && git pull
cd deploy && podman compose up -d --build podman compose up -d --build
``` ```
Data lives in the `oweme-data` volume and survives rebuilds. Data lives in the `oweme-data` volume and survives rebuilds.
## Configuration (`deploy/.env`) ## Configuration (`.env`)
| Variable | Required | Default | Purpose | | Variable | Required | Default | Purpose |
|---|---|---|---| |---|---|---|---|