Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Environment Variables

Environment variables are a question mark

Questions

  • many .env files, duplication of things like SUCH_SUCH_DOMAIN
  • many .env files, but root .env for any common vars
  • exam-platform/env/common.env
  • separate variables vs secrets (different files)
  • variables in .env, secrets in a secret store (cloud)
  • build vs runtime

Variables

“Where Set” lists the place that supplies the value. .env is the app’s own .env (copy .env.example). Komodo means the stack environment in deploy/exam-platform.toml.

apps/auth-api

NameRequiredDefaultWhere SetDescription
ENVIRONMENTyes.env, Komodo (staging)development, staging or production. Release images refuse to start without it.
SENTRY_DSNoutside developmentempty.env, Komodo (EXAM_PLATFORM_AUTH_API_SENTRY_DSN)Sentry project DSN.
SENTRY_TRACES_SAMPLE_RATEno0.2.envSentry trace sampling rate.
RUST_LOGnoinfo.envFilters what reaches stdout (development) and Sentry.
AAPI_PORTno13001.envHost port on 127.0.0.1. Container always listens on 13001.
LISTEN_ADDRno0.0.0.0:13001compose.yaml, DockerfileBind address. Do not change: baked into image.
PLATFORM_NETWORKnoplatform.envShared external Docker network name.
IMAGEnoempty.env, Komodo (EXAM_PLATFORM_AUTH_API_IMAGE)Release image to run. Empty builds from source. Komodo sets on deploys.
EDB_DATABASE_URLyes.env, Komodo (EXAM_PLATFORM_AUTH_API_EDB_DATABASE_URL)eDb Postgres URL as role aapi. No DDL: run edb-migrate first. Compose host examiner-db. Hosted: append ?sslmode=verify-full.

apps/examiner-dashboard

NameRequiredDefaultWhere SetDescription
ENVIRONMENTyes.env, Komodo (staging)development, staging or production.
SENTRY_DSNoutside developmentempty.env, Komodo (EXAM_PLATFORM_EXAMINER_DASHBOARD_SENTRY_DSN)Sentry project DSN.
SENTRY_TRACES_SAMPLE_RATEno0.2.envSentry trace sampling rate.
RUST_LOGnoinfo.envFilters what reaches stdout (development) and Sentry.
EDD_PORTno13002.envHost port on 127.0.0.1. Container always listens on 13002.
LISTEN_ADDRno0.0.0.0:13002compose.yaml, DockerfileBind address. Do not change: baked into image.
WEB_DIRnodist natively; /app/web in imageProcess environment, compose.yaml, DockerfileStatic directory relative to working directory. Client builds to apps/examiner-dashboard/dist; default works when run from the app directory. No startup check for index.html.
GOOGLE_OAUTH_IDunless mock defaults applynoneProcess environment, .env for Compose, KomodoGoogle OAuth web client ID; must not be empty.
GOOGLE_OAUTH_SECRETunless mock defaults applynoneProcess environment, .env for Compose, KomodoOAuth client secret; must not be empty.
GOOGLE_REDIRECT_URLunless mock defaults applynoneProcess environment, .env for Compose, KomodoValid callback URL registered in Google Cloud: public HTTPS origin plus /auth/google/callback.
COOKIE_KEYunless mock defaults applynoneProcess environment, .env for Compose, KomodoPrivate-cookie key, at least 64 bytes. Generate with openssl rand -hex 64; keep secret and stable. Rotation invalidates cookies.
EDB_DATABASE_URLyesnoneProcess environment, .env for Compose, KomodoeDb Postgres URL as role edd. Compose host examiner-db. Hosted: append ?sslmode=verify-full.
MOCK_AUTHnofalseProcess environmentDebug-only mock auth. Release builds reject true; Compose does not forward it. Defaults for OAuth/key fields apply only when unset, not empty.
PLATFORM_NETWORKnoplatform.envShared external Docker network name.
IMAGEnoempty.env, Komodo (EXAM_PLATFORM_EXAMINER_DASHBOARD_IMAGE)Release image to run. Empty builds from source. Komodo sets on deploys.

migrate service (apps/auth-api, apps/examiner-dashboard)

One-shot service in each backend’s compose.yaml, profile migrate: runs the image’s edb-migrate. Gets only these.

NameRequiredDefaultWhere SetDescription
MIGRATE_IMAGEyesemptyKomodo (EXAM_PLATFORM_<APP>_MIGRATE_IMAGE, by deploy Action)Image whose edb-migrate runs. Never built: empty fails.
EDB_MIGRATOR_URLyesemptydatabases/examiner/.env, Komodo (EXAM_PLATFORM_EXAMINER_DB_MIGRATOR_URL)eDb Postgres URL as role edb_migrator. Also cargo sqlx’s URL (sqlx.toml).

migrate-cdb service (apps/examiner-dashboard only)

One-shot service in eDd’s compose.yaml, profile migrate: runs the image’s cdb-migrate, after migrate. Gets only these. aAPI never migrates cDb.

NameRequiredDefaultWhere SetDescription
MIGRATE_IMAGEyesemptyKomodo (EXAM_PLATFORM_EXAMINER_DASHBOARD_MIGRATE_IMAGE, by deploy Action)Image whose cdb-migrate runs. Never built: empty fails.
CDB_MIGRATOR_URLyesemptyKomodo (EXAM_PLATFORM_CURRICULUM_DB_MIGRATOR_URL)mysql://root:<CDB_ROOT_PASSWORD>@curriculum-db:3306/curriculum: root until app roles exist. Names the database, never a curriculum/<branch> revision. Also cargo sqlx‘s URL (sqlx.toml) and the cdb tests’ server (unset: they skip).

Native dashboard execution needs exported environment variables; copying .env alone does not load them. Export them first: set -a; source .env; set +a. Mock mode defaults to test credentials/key and http://127.0.0.1:13002/auth/google/callback. Both need a running, migrated eDb.

apps/web-app

NameRequiredDefaultWhere SetDescription
AUTH_API_URLyeshttp://127.0.0.1:13001.env, KomodoRuntime. Auth API origin the browser calls, served as /config.js. Default in dev only.
WAPP_PORTno13003.envHost port on 127.0.0.1. Container always listens on 13003.
PLATFORM_NETWORKnoplatform.envShared external Docker network name.
IMAGEnoempty.env, Komodo (EXAM_PLATFORM_WEB_APP_IMAGE)Release image to run. Empty builds from source. Komodo sets on deploys.

apps/desktop-app

NameRequiredDefaultWhere SetDescription
ENVIRONMENTnoproduction.env, compile timedevelopment, staging or production. Read with env!.
SENTRY_DSNunless ENVIRONMENT=developmentempty.env, compile timeSentry project DSN. Empty disables Sentry in development.
AUTH_API_URLunless ENVIRONMENT=developmenthttp://127.0.0.1:13001 in development.envAuth API origin.

databases/curriculum

NameRequiredDefaultWhere SetDescription
CDB_ROOT_PASSWORDyes.envDolt root: openssl rand -hex 32. Creates root on an empty volume only; also the healthcheck’s.
CDB_PORTno13306.envHost port on 127.0.0.1. Container always listens on 3306.
PLATFORM_NETWORKnoplatform.envShared external Docker network name.

deploy/

Set in deploy/.env on the Droplet. bootstrap.sh copies .env.example, then fills each empty secret once with openssl rand -hex 32.

NameRequiredDefaultWhere SetDescription
KOMODO_DOMAINyesexam-platform.freecodecamp.devdeploy/.envKomodo public name. DNS points at the Droplet.
AUTH_API_DOMAINyesauth-api.freecodecamp.devdeploy/.envCaddy host for auth API.
EXAMINER_DASHBOARD_DOMAINyesexaminer-dashboard.freecodecamp.devdeploy/.envCaddy host for examiner dashboard.
WEB_APP_DOMAINyesweb-app.freecodecamp.devdeploy/.envCaddy host for web app.
KOMODO_INIT_ADMIN_USERNAMEyesadmindeploy/.envFirst admin, created on first start only.
KOMODO_INIT_ADMIN_PASSWORDyesgenerateddeploy/.env (bootstrap)First admin password. Change after login.
KOMODO_DATABASE_USERNAMEyeskomododeploy/.envMongoDB root user, created on first start only.
KOMODO_DATABASE_PASSWORDyesgenerateddeploy/.env (bootstrap)MongoDB root password.
KOMODO_JWT_SECRETyesgenerateddeploy/.env (bootstrap)Signs login sessions. Rotating logs everyone out.
KOMODO_WEBHOOK_SECRETyesgenerateddeploy/.env (bootstrap)Authenticates webhooks. None configured, but Core requires one.
KOMODO_GOOGLE_OAUTH_ENABLEDnofalsedeploy/.envEnables Google login for Komodo.
KOMODO_GOOGLE_OAUTH_IDnoemptydeploy/.envGoogle Cloud OAuth client ID. Set by hand, restart Core.
KOMODO_GOOGLE_OAUTH_SECRETnoemptydeploy/.envGoogle Cloud OAuth client secret. Set by hand, restart Core.

Komodo variables

Per app, EXAM_PLATFORM_<APP>_, with <APP> one of AUTH_API, EXAMINER_DASHBOARD, WEB_APP.

NameRequiredDefaultWhere SetDescription
EXAM_PLATFORM_<APP>_IMAGEyesKomodo, written by deploy ActionImage the stack runs. Set before each deploy, so may be unhealthy.
EXAM_PLATFORM_<APP>_IMAGE_HEALTHYnoKomodo, written by deploy ActionLast image confirmed healthy. Rollback target.
EXAM_PLATFORM_<APP>_IMAGE_PREVIOUSnoKomodo, written by deploy ActionHealthy image before that. Target for previous.
EXAM_PLATFORM_<APP>_MIGRATE_IMAGEnoKomodo, written by deploy ActionaAPI and eDd: image whose migrators the migrate (and eDd’s migrate-cdb) services run.
EXAM_PLATFORM_AUTH_API_SENTRY_DSNyesKomodoPassed to auth-api as SENTRY_DSN.
EXAM_PLATFORM_EXAMINER_DASHBOARD_SENTRY_DSNyesKomodoPassed to examiner-dashboard as SENTRY_DSN.

Dashboard, aAPI, eDb and cDb also require these Komodo Variables (no defaults):

NameDescription
EXAM_PLATFORM_EXAMINER_DASHBOARD_GOOGLE_OAUTH_IDPassed as GOOGLE_OAUTH_ID.
EXAM_PLATFORM_EXAMINER_DASHBOARD_GOOGLE_OAUTH_SECRETSecret; passed as GOOGLE_OAUTH_SECRET.
EXAM_PLATFORM_EXAMINER_DASHBOARD_GOOGLE_REDIRECT_URLRegistered callback; passed as GOOGLE_REDIRECT_URL.
EXAM_PLATFORM_EXAMINER_DASHBOARD_COOKIE_KEYSecret; passed as COOKIE_KEY.
EXAM_PLATFORM_EXAMINER_DASHBOARD_EDB_DATABASE_URLSecret; passed as EDB_DATABASE_URL.
EXAM_PLATFORM_EXAMINER_DB_PASSWORDSecret; eDb stack passes it as EDB_PASSWORD (superuser postgres).
EXAM_PLATFORM_EXAMINER_DB_MIGRATOR_PASSWORDSecret; eDb stack passes it as EDB_MIGRATOR_PASSWORD (role edb_migrator, empty volume only).
EXAM_PLATFORM_EXAMINER_DB_MIGRATOR_URLSecret; aAPI and eDd stacks pass it as EDB_MIGRATOR_URL to their migrate service only.
EXAM_PLATFORM_EXAMINER_DB_EDD_PASSWORDSecret; eDb stack passes it as EDB_EDD_PASSWORD (role edd, empty volume only).
EXAM_PLATFORM_EXAMINER_DB_AAPI_PASSWORDSecret; eDb stack passes it as EDB_AAPI_PASSWORD (role aapi, empty volume only).
EXAM_PLATFORM_AUTH_API_EDB_DATABASE_URLSecret; aAPI stack passes it as EDB_DATABASE_URL.
EXAM_PLATFORM_CURRICULUM_DB_ROOT_PASSWORDSecret; cDb stack passes it as CDB_ROOT_PASSWORD (Dolt root, empty volume only).
EXAM_PLATFORM_CURRICULUM_DB_MIGRATOR_URLSecret; eDd stack passes it as CDB_MIGRATOR_URL to its migrate-cdb service only.

GitHub Actions

NameRequiredDefaultWhere SetDescription
DOCR_REGISTRYreleaseGitHub varDigitalOcean registry name.
KOMODO_URLdeployGitHub var (env staging)https://<KOMODO_DOMAIN>.
KOMODO_API_KEYrelease, deployGitHub secretKomodo API key. Needs Execute on the deploy Action only.
KOMODO_API_SECRETrelease, deployGitHub secretKomodo API secret.
DIGITALOCEAN_USERNAMEreleaseGitHub secretDigitalOcean access token email address.
DIGITALOCEAN_ACCESS_TOKENreleaseGitHub secretRegistry login and doctl.