Environment Configuration
Overview
The Rhesis backend uses environment variables for configuration, allowing for different settings across development, testing, and production environments. This approach follows the 12-factor app methodology for configuration management.
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 sensitive values to version control
- ⚠️ Use different keys and secrets for dev, staging, and production
- ⚠️ Back up production keys securely
- ⚠️ Store in secure secret management systems (GCP Secret Manager, AWS Secrets Manager, etc.)
- ⚠️ Rotate secrets regularly
- ⚠️ Use environment-specific configurations for production
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