Environment Configuration
Overview
Configuration is environment variables (see 12-factor app ); different files and hosts supply values per environment.
Environment Variables Reference
For a complete list of all environment variables, their requirements, and descriptions, see the Environment Variables.
Environment Files
The application supports multiple environment files:
.env: Default environment file for local development.env.docker: Environment configuration for Docker deployment.env.test: Environment configuration for testing (not committed to version control)
Loading Environment Variables
Environment variables are loaded using the python-dotenv library:
Environment-Specific Configuration
The application can load different configuration based on the environment:
Configuration Validation
The application validates critical configuration at startup:
Docker Environment
When running in Docker, environment variables can be passed in several ways:
- Through the
environmentsection indocker-compose.yml - Using the
--env-fileflag withdocker run - Setting individual variables with
-eflags
Example Docker Compose configuration:
Cloud Deployment
For cloud deployments, environment variables should be set using the cloud provider’s secrets or environment configuration:
- Google Cloud: Secret Manager and environment variables in Cloud Run
- AWS: Parameter Store/Secrets Manager and environment variables in ECS/Lambda
- Azure: Key Vault and App Configuration
Security Best Practices
Never commit secrets. Use distinct keys per environment, store them in a secret manager, rotate periodically, and keep production config separate from dev.
Sensitive Information
Sensitive information such as API keys and passwords should never be committed to version control. Instead:
- Use placeholder values in
.env.example - Document the required variables in the Environment Setup Guide
- Use secrets management in production environments