eabc96371b
- Updated .env.example to recommend using docker.env and secrets for sensitive data. - Modified .gitignore to include docker.env and secrets directory. - Adjusted docker-compose.yml to utilize environment files and updated port mappings. - Implemented read_env_or_file utility for better environment variable management. - Refactored portfolio and trades routers to use the new utility for fetching environment variables. - Added integration and phase 2 test updates for new environment variable handling. - Created new documentation for Docker operations and secret management. - Added placeholder files for Docker secrets and configuration.
16 lines
369 B
Python
16 lines
369 B
Python
from pathlib import Path
|
|
import os
|
|
from typing import Optional
|
|
|
|
|
|
def read_env_or_file(name: str, default: Optional[str] = None) -> Optional[str]:
|
|
file_path = os.getenv(f"{name}_FILE")
|
|
if file_path:
|
|
return Path(file_path).read_text(encoding="utf-8").strip()
|
|
|
|
value = os.getenv(name)
|
|
if value is not None:
|
|
return value
|
|
|
|
return default
|