Add environment variables¶
Environment variables are name/value pairs that are dynamically loaded into your containers at runtime. They are often used to pass configuration details to your application. Using environment variables instead of hard-coded values lets you keep environment-specific details out of your source code.
When you define your application stack with a Uffizzi Compose file, you have two options for adding environment variables to your containers: environment
or env_file
.
-
Use
environment
if you have a small number of environment variables to add. You can list your variables in anenvironment
block within the service definition. For example, the followingdocker-compose.uffizzi.yml
snippet adds two environment variables,FOO
andBAR
, to themyservice
container:
-
Use
env_file
if you have a large number of enviroment variables that would otherwise clutter up your compose file. You can store your variables in a file within your repository and use theenv_file
component to specify the path to this file. For example, the followingdocker-compose.uffizzi.yml
snippet tells Uffizzi to read the contents ofenvs/myconfigs.env
and add them to the containermyservice
: