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.