Skip to main content

Environment variables

The complete reference. Variables marked Required must be set for a production start. Variables marked derived are computed when left empty.

Tip: anything not in .env.example has a sensible default baked into the compose file or the images — you only add it to .env to override.

Public access & URLs

VariableDefaultRequiredDescription
PUBLIC_URLhttps://ocs.example.comPublic base URL of the stack (scheme + host, optionally :port). Used to derive BACKEND_API_ROUTE and FRONTEND_REDIRECT.
FRONTEND_BASE_PATH/front/URL sub-path the UI is served under. Non-root, slash-wrapped. Runtime setting.
API_BASE_PATH/api/URL sub-path the API (and agents) are served under. Drives nginx routing and the backend FORCE_SCRIPT_NAME. Must differ from FRONTEND_BASE_PATH.
BACKEND_API_ROUTEderivedAbsolute URL the browser uses to reach the API. Empty → PUBLIC_URL + API_BASE_PATH. Set explicitly only for split-origin (API on another host).

See Base paths.

TLS & ports

VariableDefaultRequiredDescription
HTTP_PORT80Port nginx listens on for HTTP (redirects to HTTPS). Also the published host port.
HTTPS_PORT443Port nginx listens on for HTTPS. Used to build the HTTP→HTTPS redirect (the port is included only when non-default). For a non-standard port, put it in PUBLIC_URL too.

Certificates are mounted from certs/ (fullchain.pem, privkey.pem), never baked. See TLS & networking.

Django security

VariableDefaultRequiredDescription
SECRET_KEYDjango secret key. Keep it stable across upgrades or sessions/tokens are invalidated. The app refuses to start without it when DEBUG=False.
DEBUGFalseEnable Django debug mode. Accepts 1/true/yes/on. Keep False in production.
ALLOWED_HOSTS*recommendedComma-separated hostnames Django will serve. Set to your hostname(s). The loopback hosts (localhost, 127.0.0.1) are always allowed for the in-container healthcheck, so you only list your public domain(s).
CSRF_TRUSTED_ORIGINS(empty)recommendedComma-separated origins (scheme + host) trusted for CSRF / OIDC / CAS flows.
FRONTEND_REDIRECTderivedSSO only (CAS/OIDC): URL the backend redirects the browser to after a login callback, with the auth token in the URL fragment. Empty → PUBLIC_URL + FRONTEND_BASE_PATH + ocsreports. Unused for local login.
LOG_LEVELINFODjango root log level (logs go to stdout).

Database (PostgreSQL)

VariableDefaultRequiredDescription
DB_NAMEocsdbDatabase name (also creates it in the db service).
DB_USERocsuserDatabase user.
DB_PASSWORDchange-meDatabase password — set a strong value.
DB_HOSTdbDatabase host. Defaults to the db service name.
DB_PORT5432Database port.

Only PostgreSQL is supported; the engine is pinned in the image and DB_ENGINE is not exposed. (MySQL/MariaDB may be added later.)

First admin

VariableDefaultRequiredDescription
OCS_ADMIN_PASSWORDchange-merecommendedBootstrap password for the admin superuser. Applied only while the account still has its default password; once changed (here or via the UI) it is never touched again. Rotate later via the UI or manage.py changepassword.

See Admin, auth & agents.

Automation (scheduler)

VariableDefaultRequiredDescription
AUTOMATION_INTERVAL60 (compose) / 300 (in .env.example)Seconds between manage.py automation runs in the automation service.

API proxy / networking (advanced)

These have working defaults in the compose file; override only for non-standard networking.

VariableDefaultRequiredDescription
BACKEND_UPSTREAMbackend:8000host:port the frontend service proxies the API to.
BACKEND_RESOLVER127.0.0.11DNS resolver nginx uses to re-resolve the upstream at runtime (Docker embedded DNS), so the backend can be recreated without a 502. Set empty to disable runtime DNS resolution (static address).

CORS (advanced)

Front and API share one origin by default, so CORS is off. For split-origin:

VariableDefaultRequiredDescription
CORS_ALLOW_ALL_ORIGINSFalseAllow all origins (not recommended).
CORS_ALLOWED_ORIGINS(empty)Comma-separated allowed origins.
SECURE_SSL_REDIRECTFalseLet Django force HTTPS. Off by default (TLS is handled by the nginx edge).
FORCE_SCRIPT_NAMEderived from API_BASE_PATHSub-path Django mounts under. Normally derived; kept for backward compatibility.

Gunicorn tuning (advanced)

Read by backend/gunicorn.conf.py.

VariableDefaultDescription
GUNICORN_WORKERS(2 × CPU) + 1Worker processes.
GUNICORN_THREADS1Threads per worker.
GUNICORN_TIMEOUT120Worker timeout (s) — agent inventories are zlib XML and take time to parse.
GUNICORN_MAX_REQUESTS1000Recycle a worker after N requests (bounds memory).
GUNICORN_MAX_REQUESTS_JITTER100Random jitter added to the above.
GUNICORN_LOG_LEVELinfoGunicorn log level.
GUNICORN_FORWARDED_ALLOW_IPS*IPs allowed to set X-Forwarded-* (trusted internal network).

Image version

Selects which published image is pulled and run; bump to upgrade (see Upgrading).

VariableDefaultDescription
OCS_BACKEND_REF3.0.0-rc1OCS backend version — the image tag pulled (ghcr.io/…/ocsinventory-backend:<ref>).
OCS_FRONTEND_REF3.0.0-rc1OCS frontend version — the image tag pulled.

Build-time-only arguments (extra packages, pinned tool versions, custom Dockerfile) live in the developer docs — see Build arguments.

Internal / runtime control

Set automatically by compose or the entrypoints; rarely set by hand.

VariableDefaultDescription
OCS_ROLEwebSelects the backend image behaviour: init (migrate then exit), web (gunicorn), automation (scheduler loop). Set per service in compose.
DB_WAIT_TIMEOUT60Seconds the entrypoint waits for the database before failing.
MIGRATE_WAIT_TIMEOUT300Seconds web/automation wait for migrations to be applied by ocs-init.