Repository navigation
API Deployment
English · 한국어
Miroven-API remains version 0.1.0; the client is v1.2.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.
| 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.
Signup policy defaults to the bundled app/email/domains.json (DEFAULT/en, KR/ko, JP/ja).
Optional MIROVEN_EMAIL_DOMAINS_DEFAULT, MIROVEN_EMAIL_DOMAINS_KR, and
MIROVEN_EMAIL_DOMAINS_JP replace entire groups. Use identical settings across API replicas;
restart to apply changes. Do not copy the development example.com override into production.
New administrator accounts must also use an allowed domain; the admin list does not bypass
signup policy. Existing accounts retain access. Deploy updated workers before the API so
new locale-bearing mail jobs are translated; old workers remain compatible but send English.
Upgrade every API replica before relying on signup restrictions; old API code does not enforce them.
No DB migration is introduced by this policy/localization change.
Build the API image locally with docker build -t miroven-api:0.1.0 .. For integrated deployment, use the sibling Miroven checkout at tag v1.2.0 and build the client with:
docker build -t miroven-web:1.2.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.2.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.pyExpose 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.
deploy/truenas/manage.py init creates the dataset root and secrets/ as root-owned mode 0700. Generated db.env and api.env are root-owned mode 0600; an interactively entered Cloudflare Tunnel token is stored in secrets/tunnel-token, owned by UID/GID 65532:65532, mode 0400. Secret files are created exclusively with restrictive permissions, then descriptor ownership and final permissions are set before any credential is written. Existing credentials are preserved. If metadata setup fails, no secret content is written; inspect the resulting empty file privately before retrying. The mode guarantees apply on the Linux/TrueNAS host, not Windows ACLs.
Preflight rejects REPLACE placeholders. For origins, SMTP hosts, sender/username mailboxes and administrator email lists, it checks the parsed hostname against example.com and its subdomains, ignoring case and a trailing DNS dot. Unrelated domains such as myexample.com and occurrences in passwords, mailbox local parts or display names are allowed. This is template validation; the separate HTTPS-origin validation still applies.
The CodeQL py/clear-text-storage-sensitive-data finding on tunnel-token provisioning describes intentional recoverable credential storage. Cloudflared's --token-file interface requires the original token; hashing or application-level encryption would break startup without a separate secret delivery mechanism. The Compose template mounts only this file read-only into cloudflared and passes its path, keeping the token out of command arguments and deployment JSON. The token is not printed by the installer.
This is an intended-use / accepted-risk exception, not encrypted storage or a false-positive claim. After reviewing the deployment controls, a maintainer can dismiss this specific storage alert as Won't fix for this production provisioning path, with the following rationale: “cloudflared requires a recoverable token file; exclusive creation, permissions before writing, UID 65532/mode 0400, root-only parent directory, read-only container mount, and no installer output limit access. Host administrators and offline dataset/backup readers remain trusted.” Do not classify this production path as Used in tests, disable the query, or exclude the deployer globally. No alert is dismissed automatically by the code change; rerun CodeQL separately. Use encrypted datasets/backups if protection against offline storage access is required.
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.comRun 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.
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.
- Client development · 클라이언트 개발
- Self-hosting · 자체 호스팅
- PWA, offline use, and updates · PWA·오프라인·업데이트
- Client performance · 클라이언트 성능
- Architecture · 아키텍처
- Cryptographic format · 암호화 형식
- Image processing · 사진 처리
- Security model · 보안 경계
- Product principles · 제품 원칙
- Dependency licenses · 의존성 라이선스
- Account and sync · 계정과 동기화
- Backup and recovery · 백업과 복구
- Entry quotes · 기록 인용
- Profile document · 프로필 문서