Skip to main content

Environment variables

In Divio, environment variables provide a powerful and flexible way to manage configuration information in your applications, both in the cloud and on your local machine.

This allows you to store sensitive information, such as passwords and API keys, outside of your codebase and keep it secure.

Environment variables in the cloud environment

In Divio cloud applications, environment variables are used to define and configure specific settings or parameters for an application's environment.

When an application is provisioned, environment variables specific to the environment are automatically provisioned as well. Additionally, when a service is provisioned, such as a database, or an object storage, a corresponding environment variable is also provisioned. Refer to the environment variables reference for a list of BUILT-IN environment variables.

ADDITIONAL environment variables can be set by overwriting the built-in environment variables or adding new custom environment variables with varying degrees of sensitivity, such as hidden-valued environment variables.

Environment variables are displayed on the Control Panel Env Variables view of the application.

Managing environment variables

However, note that new or modified environment variables are not available for use in environments until they are redeployed.

It's important to note that environment variables should only apply to environments and not to states or processes that are independent of a particular environment.

During the build phase of your application, it should not be subject to any particular environment conditions. However, you can set environment variables during the build phase to customize the build process and ensure that your application is built with the correct settings.

Environment variables in the local environment

In addition to cloud applications, your local application also uses environment variables, which can be configured in a file called .env-local specified in the docker-compose.yml file.

The Divio CLI allows you to retrieve environment variables from the command line.

Environment variables with Aldryn (legacy)

Many of the applications packaged for Divio deployment recognise a number of environment variables for your convenience.

See Aldryn Django (core Django) for lists of settings that can be provided as variables in some Divio addons.

They do this in their Addon configuration with aldryn_config.py files. To see precisely how they are handled, refer to the aldryn_config.py file of key addons (important: make sure you are looking at the correct version of the addon, as different versions of the packages will assume different variables and settings):

Our uWSGI application gateway in Aldryn Django applications also recognises environment variables that commence UWSGI_.

For more information, see the full overview of how to manage environment variables or the Environment variables reference.