Skip to content

Environment Variables

Environment variables only cover what a process needs to start: listening port, database connection, NATS address, logging. Site behaviour (registration, moderation, email, OAuth, upload limits) is runtime configuration stored in settings, applied without a restart, and should not be baked into a compose file.

The rule of thumb: change behaviour in the admin panel, change dependencies with a restart.

VariableDefaultNotes
PORT8080HTTP listen port
DB_TYPEsqlitesqlite / mysql / postgres
DB_DSNemptyRequired for mysql / postgres; a file path for sqlite
DB_MAX_OPEN_CONNS25Maximum open connections
DB_MAX_IDLE_CONNS10Maximum idle connections
DB_CONN_MAX_LIFETIME300Maximum connection lifetime in seconds
DB_CONN_MAX_IDLE_TIME60Idle connection timeout in seconds
NATS_URLemptyRequired. External NATS with JetStream; startup fails when empty
NATS_BUCKETfeedchamber_kvJetStream KV bucket name
ADMIN_PASSWORDemptyPassword for the seeded admin; random and logged when empty
SITE_URLemptyFallback for site_url, used by sitemap and canonical
METRICS_ENABLEDtrueStart the 9091 metrics listener
METRICS_PORT9091Metrics port, internal network only
TRACING_ENABLEDtrueParse inbound traceparent and echo it back
LOG_LEVELinfodebug / info / warn / error
LOG_FORMATjsonjson / text
LOG_OUTPUTstderrstdout / stderr or a file path

These have lower priority than settings: a stored value wins, the environment variable is only a fallback for empty values. Storage changes need a restart because storage is a startup singleton.

VariableSettings keyDefault
STORAGE_PROVIDERstorage_providerlocal
STORAGE_LOCAL_DIRstorage_local_diruploads
S3_ENDPOINTs3_endpointempty
S3_REGIONs3_regionus-east-1
S3_BUCKETs3_bucketempty
S3_ACCESS_KEY_IDs3_access_key_idempty
S3_ACCESS_KEY_SECRETs3_access_key_secretempty
S3_USE_SSLs3_use_ssltrue
S3_CUSTOM_DOMAINs3_custom_domainempty
EMAIL_PROVIDERemail_providerlog
EMAIL_FROMemail_fromempty
EMAIL_FROM_NAMEemail_from_nameFeed Chamber
EMAIL_SMTP_HOSTemail_smtp_hostempty
EMAIL_SMTP_PORTemail_smtp_port587
EMAIL_USERNAMEemail_usernameempty
EMAIL_PASSWORDemail_passwordempty
EMAIL_USE_TLSemail_use_tlsfalse
EMAIL_API_KEYemail_api_keyempty

There is no time-zone variable: check-in dates and reporting windows follow the process time zone. Pin it in the container when that matters:

environment:
TZ: Asia/Shanghai

The public API base URL is injected at build time; same-origin deployments (nginx proxying /api/v1) need nothing.

VariableDefaultNotes
NEXT_PUBLIC_API_URLempty (same origin)API base URL for split-domain deployments
DOCS_SITEhttps://noelorin.github.ioDocs site only: the Pages site origin
DOCS_BASE/Docs site only: project-page path prefix

config.Validate() runs at boot and exits immediately on any violation:

  1. DB_TYPE must be sqlite, mysql, or postgres
  2. mysql / postgres require DB_DSN
  3. NATS_URL must not be empty
  4. With METRICS_ENABLED=true, METRICS_PORT must be within 1–65535