Skip to content
SEUNGWOO CHOI edited this page Oct 18, 2026 · 7 revisions

API deployment and self-hosting

English · 한국어

Miroven-API remains version 0.1.0; the client is v1.0.0. Configure domains, database, SMTP, storage, and limits through environment/Compose settings. Never publish live environment files or secrets. Commands run from the API checkout unless stated otherwise.

Production configuration

Layout Standalone Compose Example environment
Same-origin client/API compose.production.yaml .env.production.example
API-only host with separate static client compose.api.yaml .env.api.example

Copy the selected example to .env.production. Set random DB password/SECRET_KEY, matching DB URL credentials, SMTP, and fixed image tags/digests. MIROVEN_DOMAIN is the Caddy host, MIROVEN_PUBLIC_ORIGIN the app origin, and MIROVEN_API_ORIGIN the API origin, defaulting to the app origin.

Use same-origin or same-site HTTPS subdomains; unrelated sites cannot use this cookie authentication. Never allow credential CORS for arbitrary origins, the website, or previews. See authentication.

Build and start

Build the API image locally with docker build -t miroven-api:0.1.0 .. For integrated deployment, build the client in the sibling Miroven checkout with:

docker build -t miroven-web:1.0.0 --build-arg NEXT_PUBLIC_APP_URL=https://journal.example.com --build-arg NEXT_PUBLIC_MIROVEN_API_URL=/api/v1 --build-arg NEXT_PUBLIC_WEBSITE_URL=https://www.example.com .

Set MIROVEN_API_IMAGE and MIROVEN_WEB_IMAGE to the images you actually built or their digests. The API examples still contain 0.1.0 defaults; explicitly select the 1.0.0 client image when using it. Example local tags do not imply a published registry image. Transfer images to the host as needed.

Check persistent volumes, disk space, startup after reboot, and ports 80/443. On TrueNAS, separate the service IP/ports from its management UI if necessary. Back up DB and blobs together. Route public DNS/80/443 to Caddy; never expose DB/API ports directly. These examples use Caddy TLS. If adding a proxy/tunnel, configure ingress and trusted proxy scope and verify spoofed X-Forwarded-For cannot bypass limits (for TrueNAS 25.10 Custom App + Cloudflare Tunnel, deploy/truenas/manage.py and deploy/truenas/*.env.example are provided). Do not cache API responses in a CDN.

# For integrated deployment, use compose.production.yaml instead.
docker compose --env-file .env.production -f compose.api.yaml config --quiet
docker compose --env-file .env.production -f compose.api.yaml up -d --wait --wait-timeout 180
docker compose --env-file .env.production -f compose.api.yaml exec api python scripts/check_integrity.py

Expose only /api/* and check readiness internally. Restrict live env-file access to the operator. Apply migration 0004_attachments before the multi-photo client. See operations for deletion ledgers, paired backup/restore, and upgrade/rollback, and sync protocol for S3 constraints.

Static client

Build in Miroven/web/ with:

NEXT_PUBLIC_APP_URL=https://journal.example.com
NEXT_PUBLIC_MIROVEN_API_URL=https://api.example.com/api/v1
NEXT_PUBLIC_WEBSITE_URL=https://www.example.com

Run npm run build and deploy out/; the full command includes CSP/SW post-processing. For Pages: root web, build npm run build, output out, Node 22.13 or later. Empty API URL means local-only, /api/v1 means same-origin. App/website defaults refer to the official service, so set your own URLs explicitly. Rebuild on changes; runtime container environment does not rewrite static JS. Docker accepts the same three public variables as build arguments.

Apply generated out/_headers at the real host. Review policies, contacts, providers, and retention for your instance. Changing origin does not move IndexedDB: export encrypted backup at the old address and restore into an empty vault at the new one. See client self-hosting and backup.

Launch and measurement

Use validation and launch checks before serving traffic. Local tests are not public-service validation. The website handles no API credentials and preview builds must not use production API.

Reproduce baseline load with uv run python scripts/benchmark.py --base-url http://localhost:8000. For authenticated usage measurement, pass a test cookie only through MIROVEN_BENCH_SESSION. Defaults are 100 requests/concurrency 4; maxima are 10,000/concurrency 32. After warm-up it records p50/p95/max, statuses, and errors. --output accepts a new file only. Measure host resources, full sync/photos, worker load, and operating costs separately.

Clone this wiki locally