Configuration
.env.example lists supported variables. Required application groups are:
- URLs/runtime:
NODE_ENV,APP_BASE_URL,API_BASE_URL,PORT - PostgreSQL:
DATABASE_URL, optional privilegedDATABASE_MIGRATION_URL, and workerWORKER_DATABASE_URL - Jobs:
VALKEY_URL - Security:
AUTH_SECRET,ENCRYPTION_KEY - S3/SeaweedFS:
S3_ENDPOINT,S3_PUBLIC_ENDPOINT,S3_REGION,S3_BUCKET, access key, secret key, path-style mode, and SeaweedFS signing/encryption keys. Browsers upload receipts and contract PDFs straight toS3_PUBLIC_ENDPOINTwith a short-lived signed URL, so that endpoint must be reachable from users' browsers and allow cross-originPUTrequests fromAPP_BASE_URL. - SMTP: host, port, TLS mode, optional credentials, and
SMTP_FROM - Optional providers: Stripe, DocuSign, Google Calendar, Nominatim, OSRM, and AI
For host-side commands, load the file into the current Bash shell first:
. scripts/load-env.sh
corepack pnpm db:migrate
Set FISCAL_FOX_ENV_FILE before sourcing to use another file. Compose loads
.env itself. WORKER_DATABASE_URL selects the worker's least-privilege role.
The worker falls back to DATABASE_URL only for explicit host development;
production requires WORKER_DATABASE_URL.
Use different least-privilege PostgreSQL roles for migrations, API, and worker.
The Compose initialization creates fiscal_fox_migrator, fiscal_fox_app, and
fiscal_fox_worker; these literal role names are required in production and
production passwords must not reuse development values.
Before migrations, the one-shot database-owner service reconciles database and
public schema ownership to fiscal_fox_migrator, including existing Compose
volumes. Non-Compose installations must establish that ownership with a database
administrator before running migrations.
DATABASE_APP_ROLE, DATABASE_WORKER_ROLE, and DATABASE_MIGRATION_ROLE
identify the expected server-reported roles. The migrator has BYPASSRLS;
application roles do not.
Compose keeps credentials service-specific:
- API receives the app
DATABASE_URL, authentication/encryption settings, storage, Stripe webhook/Connect, the non-secretDOCUSIGN_ENABLEDindicator, Google Calendar, and map providers. - Worker receives only
WORKER_DATABASE_URL, Valkey, encryption, storage, SMTP, and the provider credentials needed for background delivery/extraction, including all DocuSign account, user, integration, and private-key values. - Database-owner receives only the bootstrap administrator connection settings required to transfer database and schema ownership before migration.
- Migrate receives only
DATABASE_MIGRATION_URL. - Web/nginx receives no provider or database secrets.
DOCUSIGN_ENABLED=true must agree between API and worker configuration and
requires worker integration key, user ID, account ID, private key, and an HTTP(S)
base path. When disabled, those worker credentials may be omitted.
Configuration aggregation parses database URL usernames, requires each to match
its declared service role, and rejects duplicate API, worker, migrator, or
database-admin identities. Validation errors report only the service, variable,
hostname, and role; they never echo a URL or password. API and worker startup
require session_user = current_user = expected role, NOSUPERUSER,
NOBYPASSRLS, NOCREATEDB, NOCREATEROLE, NOREPLICATION, and NOINHERIT.
Recursive pg_auth_members traversal rejects every unapproved membership,
including built-in PostgreSQL capability roles. The worker has no access to
authentication token, credential, session,
verification, or passkey tables; it can select only auth_user.id and
auth_user.email for attributed background accounting work. Run
corepack pnpm compose:config:verify to assert the rendered Compose boundary.
For host development only, omitting WORKER_DATABASE_URL explicitly falls back
to DATABASE_URL and emits a warning. That fallback URL must still authenticate
as DATABASE_WORKER_ROLE, and runtime role validation still applies. Production
never permits the fallback.
The plain DATABASE_*, VALKEY_URL, S3_ENDPOINT, and SMTP_* values in
.env.example are host-development endpoints. Compose deliberately wires API,
worker, and migration containers to postgres, valkey, seaweedfs, and
mailpit service DNS instead. Advanced deployments may override only that
internal wiring with COMPOSE_DATABASE_URL, COMPOSE_WORKER_DATABASE_URL,
COMPOSE_DATABASE_MIGRATION_URL, COMPOSE_VALKEY_URL,
COMPOSE_S3_ENDPOINT, COMPOSE_SMTP_HOST, and COMPOSE_SMTP_PORT.
AUTH_SECRET and ENCRYPTION_KEY must be at least 32 characters. Store secrets
outside source control and rotate them through a rehearsed process. Set the
public S3 endpoint to a browser-reachable TLS URL. Restrict PostgreSQL, Valkey,
SeaweedFS administration ports, and Mailpit from public networks.
Compose does not accept SESSION_GENERATION in the API container. A one-shot
initializer creates a random mode-600, API-owned value in the private
session-generation volume, and API startup waits for it and mounts it read-only.
Host deployments may use a mode-600 SESSION_GENERATION_FILE; the environment
fallback must be explicit and at least 32 version-safe characters.
BACKUP_HMAC_KEY_FILE, BACKUP_HMAC_KEY_ID, and
FISCAL_FOX_RELEASE_REVISION are host-only backup metadata settings and are
never passed into application containers. The key file must be outside the
application directory, build context, and backup tree with mode 600; see
Backup and restore.
Backup and restore share one deployment-wide atomic operation lock. Override
FISCAL_FOX_OPERATION_LOCK_DIR only with an operator-owned path; stale removal
requires the explicit FISCAL_FOX_OPERATION_LOCK_BREAK_STALE=1 recovery action.
Demo-only variables are ALLOW_DEMO_SEED, DEMO_ORGANIZATION_ID, and
DEMO_USER_EMAIL. They are never required by normal runtime services.