Skip to Content
ContributeBackendEnvironment Configuration

Environment Configuration

The backend is configured through environment variables. For the full variable catalog, see the Environment Variables reference; for local-dev knobs, see Environment Variables under Contribute. This page covers the backend-specific conventions those references assume.

Environment files

  • .env — local development (written by ./rh dev init; see the Backend Overview)
  • .env.docker — Docker Compose
  • .env.test — test runs (not committed)

Runtime environment label

BACKEND_ENV is the canonical runtime environment label in Python settings and logging. Valid values are production, development, staging, and local; anything else fails validation at startup.

settings.py
from rhesis.backend.app.config.settings import get_application_settings

settings = get_application_settings()

if settings.is_production:
    ...
elif settings.is_development:
    ...

Shell entrypoints may still read ENVIRONMENT for deployment-script behavior, but application code should use BACKEND_ENV.

Database credentials

Database URLs are built from component variables. Runtime application sessions use APP_DB_USER / APP_DB_PASS; migrations and administrative jobs use ADMIN_DB_USER / ADMIN_DB_PASS when present and fall back to the app credentials for single-role local setups.

VariableRequiredUsed for
DB_DRIVERNo, defaults to postgresqlSQLAlchemy driver
DB_HOSTYesDatabase host or Unix socket path
DB_PORTNo, defaults to 5432TCP port when DB_HOST is not a socket
DB_NAMEYesDatabase name
APP_DB_USERYes for runtime backend and workersLeast-privilege application database role
APP_DB_PASSYes when APP_DB_USER is setApplication role password
ADMIN_DB_USEROptionalMigration or admin database role
ADMIN_DB_PASSRequired when ADMIN_DB_USER is setAdmin role password

Managed Postgres deployments should use a separate migration role through ADMIN_DB_* and a least-privilege runtime role through APP_DB_*. RLS-aware migrations do not require a PostgreSQL superuser.

Secrets

Never commit secrets. Use placeholder values in .env.example, distinct keys per environment, and a secret manager in production. See Deployment for how secrets are supplied to cloud runtimes.