Skip to content

Environment variables

The first steps of the Getting Started guide mention creating an .env file.

The sections below outline in more detail the application environment variables that you may want to override, and their purpose. In App Service, this is more generally called the “configuration”.

See other topic pages in this section for more specific environment variable configurations.

Docker

COMPOSE_PROJECT_NAME

Local configuration

This setting only affects the app running on localhost

Name that Docker Compose prefixes to the project for container runs.

Amplitude

ANALYTICS_KEY

Deployment configuration

You may change this setting when deploying the app to a non-localhost domain

Amplitude API key for the project where the app will direct events.

If blank or an invalid key, analytics events aren’t captured (though may still be logged).

Django

DJANGO_ADMIN

Boolean:

  • True: activates Django’s built-in admin interface for content authoring.
  • False (default): skips this activation.

DJANGO_ALLOWED_HOSTS

Deployment configuration

You must change this setting when deploying the app to a non-localhost domain

A list of strings representing the host/domain names that this Django site can serve.

DJANGO_DEBUG

Deployment configuration

Do not enable this in production

Django docs

Settings: DEBUG

Boolean:

  • True: the application is launched with debug mode turned on, allows pausing on breakpoints in the code, changes how static files are served
  • False (default): the application is launched with debug mode turned off, similar to how it runs in production

DJANGO_LOCAL_PORT

Local configuration

This setting only affects the app running on localhost

The port used to serve the Django application from the host machine (that is running the application container).

i.e. if you are running the app in Docker on your local machine, this is the port that the app will be accessible from at http://localhost:$DJANGO_LOCAL_PORT

From inside the container, the app is always listening on port 8000.

DJANGO_LOG_LEVEL

Deployment configuration

You may change this setting when deploying the app to a non-localhost domain

The log level used in the application’s logging configuration.

By default the application sends logs to stdout.

DJANGO_SECRET_KEY

Deployment configuration

You must change this setting when deploying the app to a non-localhost domain

Django docs

Settings: SECRET_KEY

Django’s primary secret, keep this safe!

DJANGO_TRUSTED_ORIGINS

Deployment configuration

You must change this setting when deploying the app to a non-localhost domain

Comma-separated list of hosts which are trusted origins for unsafe requests (e.g. POST)

HEALTHCHECK_USER_AGENTS

Deployment configuration

You must change this setting when deploying the app to a non-localhost domain

Comma-separated list of User-Agent strings which, when present as an HTTP header, should only receive healthcheck responses. Used by our HealthcheckUserAgents middleware.

requests configuration

requests docs

Docs for timeouts

REQUESTS_CONNECT_TIMEOUT

The number of seconds requests will wait for the client to establish a connection to a remote machine. Defaults to 3 seconds.

REQUESTS_READ_TIMEOUT

The number of seconds the client will wait for the server to send a response. Defaults to 1 second.

Cypress tests

Cypress docs

CYPRESS_* variables

CYPRESS_baseUrl

The base URL for the (running) application, against which all Cypress .visit() etc. commands are run.

When Cypress is running inside the devcontainer, this should be http://localhost:8000. When Cypress is running outside the devcontainer, check the DJANGO_LOCAL_PORT.

Sentry

SENTRY_DSN

Enables sending events to Sentry.

SENTRY_ENVIRONMENT

Segments errors by which deployment they occur in. This defaults to local, and can be set to match one of the environment names.

SENTRY_REPORT_URI

Collect information on Content-Security-Policy (CSP) violations. Read more about CSP configuration in Benefits.

To enable report collection, set this env var to the authenticated Sentry endpoint.

SENTRY_TRACES_SAMPLE_RATE

Sentry docs

traces_sample_rate

Control the volume of transactions sent to Sentry. Value must be a float in the range [0.0, 1.0].

The default is 0.0 (i.e. no transactions are tracked).