Skip to Content
Bryfo Docsv0.2.1

Environment Variables Reference

Exhaustive reference for all Bryfo bootstrap environment variables, first-boot admin seeds, container resource limits, and hot-reloadable /admin overrides.

Bryfo separates configuration into two clear layers:

  1. Immutable Infrastructure Bootstrap (.env, requires process restart): Network listeners, trusted reverse-proxy CIDRs, PostgreSQL / Valkey connection parameters, and the master AES-256-GCM CREDENTIALS_ENCRYPTION_KEYS keyring.
  2. Hot-Reloaded Operational Policies (PostgreSQL system_settings + Valkey Pub/Sub): OIDC SSO, Google/Microsoft Mail XOAUTH2, Cloudflare Turnstile, S3/R2 object storage (DynamicStore), System SMTP, AI providers & pricing, Stalwart mailserver, and payment gateways.

Precedence Rule: /admin Database Settings Override Optional Seed Variables

Optional seed environment variables (OIDC_*, S3_*, SYSTEM_SMTP_*, AI_*, STRIPE_*, LOG_LEVEL, etc.) act purely as initial fallback defaults when no setting has been saved in /admin yet. Once you save a configuration in /admin/*, the encrypted database record takes precedence across all api and worker nodes immediately without restarting containers.


1. Core Bootstrap, URL & Cryptography

VariableKindDefaultFormat / Behavior
DEPLOYMENT_MODEBootstrapself_hostedself_hosted (unlimited local quotas, billing off, private LAN mail/site-AI permitted) or cloud (multi-tenant subscriptions, dual-pool ledger, strict public-only netguard egress, 2 MiB IMAP on-demand threshold, active-window IDLE).
APP_PUBLIC_URLRequiredhttp://localhost:8080External origin without trailing slash (e.g. https://mail.example.com). Controls CSRF Origin/Referer verification, OIDC/XOAUTH2 callback URLs, and auto-enables COOKIE_SECURE=true when starting with https://.
CREDENTIALS_ENCRYPTION_KEYSRequired—Comma-separated versioned 32-byte Base64 AES-256-GCM keys: 1:<base64>[,2:<base64>] (v1:<base64> and bare <base64> also parse as version 1; all-zero keys fail at boot). Generate via echo "1:$(openssl rand -base64 32)".
SESSION_SECRETOptional BootstrapHKDF-derivedDerived automatically from the primary CREDENTIALS_ENCRYPTION_KEYS key (bryfo/session-secret/v1) via HKDF-SHA256 when unset.
COOKIE_SECUREOptional Bootstraptrue on https://Overrides the Secure attribute on bryfo_session (HttpOnly, SameSite=Lax, 7d sliding / 30d absolute TTL).
TRUSTED_PROXIESBootstrapEmpty (127.0.0.1/32 in template)Comma-separated IPs or CIDRs (127.0.0.1/32,172.16.0.0/12) allowed to supply X-Forwarded-For, X-Real-IP, and X-Forwarded-Proto. Untrusted peers are ignored.
PUBLIC_CORS_ORIGINSOptional BootstrapSibling apex / wwwExtra comma-separated origins allowed on read-only /api/v1/public/plans and /api/v1/auth/providers for external landing sites.

2. Initial Administrator Seed (First Boot Only)

VariableKindDefaultFormat / Behavior
BOOTSTRAP_ADMIN_EMAILFirst-Boot SeedEmptyEmail address for the initial admin user. Applied only when SELECT COUNT(*) FROM users == 0 and both email + password are set.
BOOTSTRAP_ADMIN_PASSWORDFirst-Boot SeedEmptyInitial admin password (8–128 characters/bytes; "ChangeMe123!" is rejected at boot). Hashed with Argon2id; safe to delete from .env after first login.
BOOTSTRAP_ADMIN_NAMEFirst-Boot SeedAdminDisplay name assigned to the bootstrapped administrator account.

3. Process Topology, Listeners, Queues & Container Limits

VariableKindDefaultFormat / Behavior
APP_MODEBootstrapallall (HTTP + SSE + /mcp + IDLE + Asynq worker in one process), api (stateless web/API/SSE/MCP tier), or worker (Asynq + cron + internal health/metrics server).
BRYFO_LISTEN_HOSTBootstrap127.0.0.1 (Compose)Host interface bound by Docker port mapping and bryfo binary (127.0.0.1 behind local reverse proxy; 0.0.0.0 for LAN/container-network exposure).
BRYFO_HTTP_PORTBootstrap8080TCP port (1–65535). Often set to 18090 on multi-service hosts.
LISTEN_ADDROptional BootstrapDerived from aboveExplicit Go host:port override (e.g. :8080); takes precedence over BRYFO_LISTEN_HOST + BRYFO_HTTP_PORT inside the binary.
WEB_DIST_DIROptional Bootstrap/srv/web (in image)Directory containing built frontend SPA static assets.
WORKER_CONCURRENCYBootstrap4Concurrent Asynq job workers per all / worker process (critical:6, default:3, low:1 weighted priority).
WORKER_METRICS_ADDROptional BootstrapFalls back to LISTEN_ADDRInternal HTTP bind address (host:port or :port) exposing /healthz, /readyz, and /metrics when APP_MODE=worker.
ASYNQ_TASK_RETENTIONBootstrap24hGo duration string (24h, 12h) controlling how long completed Asynq task results remain in Valkey.
BRYFO_IMAGECompose Variableghcr.io/bryfo/bryfo:latestContainer image tag pulled by docker-compose.yml (pin explicit semver tags such as ghcr.io/bryfo/bryfo:v0.2.0 in production).
BRYFO_APP_MEM_LIMITCompose Variable1gMemory cap on the app service in deploy/docker-compose.yml.
BRYFO_PG_MEM_LIMITCompose Variable1536mMemory cap on postgres (shm_size defaults to 256m).
BRYFO_VALKEY_MEM_LIMITCompose Variable512mMemory cap on valkey (internal --maxmemory defaults to 384mb with noeviction).

4. PostgreSQL 17 (pgvector) & Valkey 8

VariableKindDefaultFormat / Behavior
DATABASE_URLBootstrapBuilt from PG*Full postgres://... DSN. If omitted, Bryfo safely constructs and URL-encodes the DSN from PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE, and PGSSLMODE.
POSTGRES_PASSWORD / PGPASSWORDRequired—Password for PostgreSQL (PGHOST=postgres, PGPORT=5432, PGUSER=bryfo, PGDATABASE=bryfo, PGSSLMODE=disable inside Compose).
DB_MAX_CONNSBootstrap16Maximum pgxpool connections per process (>= 1).
AUTO_MIGRATEBootstraptrueRuns embedded SQL migrations 0001–0019 at startup under pg_advisory_lock(7418529630147) with SHA-256 checksum validation. Set false if running bryfo migrate manually in CI/CD.
REDIS_ADDRBootstrap127.0.0.1:6379 (valkey:6379 in Compose)Valkey / Redis host:port endpoint.
REDIS_PASSWORDOptional BootstrapEmptyEnables --requirepass in deploy/docker-compose.yml and authenticates Go Valkey clients when non-empty.
REDIS_DBOptional Bootstrap0Integer database index (0–15).

5. Object Storage, Mail Egress & IMAP IDLE

VariableKindDefaultUI Override & Notes
BLOB_DIRBootstrap./data/blobs (/data/blobs in Docker)Filesystem root for STORAGE_BACKEND=local (sha256/<2>/<2>/<sha256>).
STORAGE_BACKENDOptional Seedlocallocal or s3. Hot-switchable live in /admin/infra.
S3_ENDPOINTOptional SeedEmptyCustom S3 HTTPS endpoint (e.g., https://<accountid>.r2.cloudflarestorage.com). Leave empty for standard AWS S3 regional endpoints.
S3_BUCKETOptional SeedEmptyTarget bucket name (HeadBucket probe available in /admin/infra).
S3_REGIONOptional SeedautoRegion identifier (auto for Cloudflare R2; e.g. us-east-1 for AWS S3).
S3_ACCESS_KEY_ID / S3_SECRET_ACCESS_KEYOptional SeedEmptyS3 credentials (KeyRing-encrypted when saved via /admin/infra).
S3_FORCE_PATH_STYLEOptional SeedfalseSet true for Garage, SeaweedFS, or path-style S3 gateways; keep false for AWS S3, Cloudflare R2, and Aliyun OSS.
S3_PRESIGN_DOWNLOADOptional SeedfalseIssues 302 presigned S3 redirects only on explicit ?download=1 (non-preview) attachment downloads so inline/preview requests remain same-origin under SandboxMediaCSP.
STORAGE_ONDEMAND_THRESHOLD_BYTESOptional Seed0 (self_hosted) / 2097152 (cloud)Attachments larger than this byte threshold (> 0) store metadata only and stream on demand from IMAP (<= 35 MiB) into a 7-day ephemeral cache. Hot-reloadable in /admin/infra.
MAIL_ALLOW_PRIVATE_SERVERSBootstraptrue (self_hosted) / false (cloud)Permits private LAN/VPN IMAP & SMTP addresses in self_hosted mode. Hard-forced to false in cloud mode regardless of env var.
IDLE_ACTIVE_WINDOW_MINUTESOptional Seed30Active tenant window (user:active:<uid>) keeping live IMAP IDLE sockets open in cloud mode (/admin/infra).
IDLE_OFFLINE_POLL_INTERVAL_MINUTESOptional Seed15Background Asynq IMAP poll interval for inactive cloud tenants (/admin/infra).

6. OIDC, Mail XOAUTH2, System SMTP, Turnstile & Web Push Seeds

All settings below are preferably configured in /admin/security (where secrets are encrypted at rest with KeyRing and hot-reloaded):

VariableDefaultNotes
OIDC_ENABLED / OIDC_AUTO_REGISTERfalse / falseEnables OIDC SSO button on /login and controls automatic account creation for verified IdP emails (email_verified == true).
OIDC_PROVIDER_NAMESSOButton label shown on /login (e.g. Pocket ID, Authentik, Okta).
OIDC_ISSUER_URLEmptyOIDC discovery base URL (without /.well-known/openid-configuration). Callback URL: ${APP_PUBLIC_URL}/api/v1/auth/oidc/callback.
OIDC_CLIENT_ID / OIDC_CLIENT_SECRETEmptyOIDC confidential client credentials.
GOOGLE_OAUTH_CLIENT_ID / GOOGLE_OAUTH_CLIENT_SECRETEmptyEnables 1-click Gmail XOAUTH2 linking (${APP_PUBLIC_URL}/api/v1/accounts/oauth/google/callback).
MICROSOFT_OAUTH_CLIENT_ID / MICROSOFT_OAUTH_CLIENT_SECRETEmptyEnables 1-click Outlook / M365 XOAUTH2 linking (${APP_PUBLIC_URL}/api/v1/accounts/oauth/microsoft/callback).
SYSTEM_SMTP_HOST / SYSTEM_SMTP_PORTEmpty / 587Outbound transactional SMTP relay for registration codes, password resets, and security alerts.
SYSTEM_SMTP_SECURITYstarttlsstarttls (port 587), tls (implicit TLS port 465), or none (trusted internal relay only).
SYSTEM_SMTP_USERNAME / SYSTEM_SMTP_PASSWORD / SYSTEM_SMTP_FROMEmptyTransactional SMTP auth credentials and From address (e.g. Bryfo <noreply@example.com>).
TURNSTILE_SITE_KEY / TURNSTILE_SECRET_KEYEmptyCloudflare Turnstile bot protection on registration and password reset forms.
VAPID_PUBLIC_KEY / VAPID_PRIVATE_KEY / VAPID_SUBJECTAuto-generatedWeb Push VAPID keys. If left empty, Bryfo automatically generates an ECDSA P-256 keypair on first boot and persists it encrypted in system_settings.

7. Site AI, Sidecars, Billing, Observability & Backups

VariableDefaultUI Override & Notes
AI_BASE_URL / AI_API_KEYhttps://openrouter.ai/api/v1 / EmptyDefault site LLM OpenAI-compatible endpoint & key (/admin/ai).
AI_CHAT_MODEL / AI_CLASSIFY_MODELopenai/gpt-4.1-mini / openai/gpt-4.1-nanoDefault chat/summarize/compose model and background classification model (/admin/ai).
AI_EMBEDDING_BASE_URL / AI_EMBEDDING_API_KEY / AI_EMBEDDING_MODELEmpty / Empty / openai/text-embedding-3-smallSeparate vector embedding endpoint & model (<= 2000 dims uses vector HNSW; 2001–4000 dims uses halfvec HNSW).
AI_USER_AGENT / AI_EMBEDDING_USER_AGENTEmptyOptional custom HTTP User-Agent sent to upstream AI gateways.
AI_ALLOW_PRIVATE_ENDPOINTStrue (self_hosted) / false (cloud)Allows site admins in self_hosted mode to point Site AI at LAN Ollama/vLLM. User BYOK always forces public-only egress (ForcePublicOnly: true) in every mode.
AI_EMBEDDING_SIDECAR_HOSTSembedding,ollamaComma-separated internal Docker service hostnames permitted for local embedding/LLM sidecars.
MAILSERVER_SIDECAR_HOSTSstalwartComma-separated internal Docker service hostnames permitted for the managed Stalwart sidecar (/admin/mailserver).
BILLING_ENABLEDfalse (self_hosted) / true (cloud)Enables /billing/*, /admin/plans, /admin/orders, and /api/v1/public/plans (/admin/security).
STRIPE_SECRET_KEY / STRIPE_WEBHOOK_SECRET / STRIPE_PUBLISHABLE_KEY / STRIPE_CURRENCYEmpty (USD)Seed credentials for Stripe Checkout & /api/v1/webhooks/stripe (/admin/orders).
LOG_LEVEL / LOG_FORMATinfo / textdebug, info, warn, error (LOG_LEVEL hot-reloads via /admin/infra); LOG_FORMAT=json recommended in production.
METRICS_TOKENEmptyBearer token authenticating GET /metrics for Prometheus (/admin/infra supports live rotation).
SENTRY_DSNEmptyOptional Sentry or self-hosted GlitchTip DSN for backend panic/error capture (/admin/infra).
BACKUP_DIR / AGE_KEY_FILE./backups / EmptyUsed by scripts/backup.sh and scripts/restore.sh for snapshot output path and age encryption/decryption identity.

On this page