Feelcouch ProjectsHandbook · v1.47.0

Architecture

Tenant deployment topology

Tenant applications share one release runtime digest and one separately built migrator digest. Each tenant has a dedicated PostgreSQL database and least-privilege role in the shared cluster. The platform registry contains deployment metadata, never database passwords. PostgreSQL, Caddy and Gatus remain shared infrastructure; tenant Compose files create only application and migration services.

Generate and validate

scripts/gen-tenant-compose.mjs consumes the schema-version 1 registry projection. It renders only active tenants in stable identifier order, validates the entire batch before writing, and rejects mutable image tags and malformed identities, hostnames or database identifiers. An absent registry or an empty active set produces no files. Repeated generation with identical inputs produces identical output. Inactive tenants' previous files are retained; generation does not start or stop containers.

Set FEELCOUCH_IMAGE_DIGEST and FEELCOUCH_MIGRATOR_IMAGE_DIGEST to the attested sha256: digests from the same release. Set TENANT_DB_HOST to the shared PostgreSQL hostname reachable on the database network, TENANT_DATABASE_NETWORK to its existing Docker backend network, and SHARED_PROXY_NETWORK to the separate reverse-proxy frontend network. Then run:

node scripts/gen-tenant-compose.mjs --dry-run
node scripts/gen-tenant-compose.mjs

The generator embeds compose.tenant.base.yaml into a self-contained deploy/tenants/<id>/compose.yaml. Each tenant has a distinct internal network and joins the external shared proxy and database networks. PostgreSQL remains on its backend network; do not attach it to the proxy frontend. Both networks must already exist, and Compose rejects missing network environment values. Shared networks permit peer network access: tenant data isolation is enforced by dedicated database roles and revoking PUBLIC CONNECT, not by the tenant internal network alone. Applications wait for successful migration; both services use log rotation and prohibit privilege escalation. Migration runs Prisma deploy only, without demo or tenant content seeding. Prisma remains the sole schema writer until an approved Liquibase baseline cutover.

Provision and retry

npm run tenant -- provision --id acme --host acme.example.com --dry-run validates the generated deployment without connecting to PostgreSQL or writing credentials. Actual provisioning requires the platform and administrator database URLs and the two release digests. It reuses the existing database/role provisioning and registry export functions, then writes Compose and aggregate monitoring files.

The single existing credential writer creates a mode-0600 secrets.env before role creation. Retries reuse that password, including after an interrupted provision; they do not rotate it or print it. Operators complete the session secret, Telegram integration and privacy-policy URL in this untracked file. The generated database URL contains no password: the application receives PGPASSWORD, while the migrator constructs its authenticated URL only in its child process environment.

Validate locally with the tenant directory as the Compose project directory so relative env_file paths resolve correctly:

docker compose --project-directory deploy/tenants/acme --env-file deploy/tenants/acme/secrets.env -f deploy/tenants/acme/compose.yaml config --quiet

Provisioning never invokes Docker or changes Caddy. The operator reviews host routing and secrets, promotes the same digests through the rollout contract, and checks the tenant's /api/health after deployment. Keep the previous runtime digest available for rollback. No live client is provisioned by generator tests.

Capacity boundary

Reassess the shared cluster at hundreds of small tenants using measured connection pressure, storage growth and migration duration; see data isolation. Introduce pooling or move an oversized tenant to its own cluster when those measurements justify it. This implementation sets no invented numeric capacity guarantee.