51 lines
1.8 KiB
Python
51 lines
1.8 KiB
Python
import os
|
|
from pydantic_settings import BaseSettings
|
|
from typing import List
|
|
|
|
# Docker-first: load secrets from mounted files when env vars are absent
|
|
_PG_SECRET_FILE = os.getenv("POSTGRES_PASSWORD_FILE", "/run/secrets/postgres-password")
|
|
if not os.getenv("POSTGRES_PASSWORD"):
|
|
try:
|
|
with open(_PG_SECRET_FILE, 'r') as f:
|
|
os.environ["POSTGRES_PASSWORD"] = f.read().strip()
|
|
except Exception:
|
|
# Leave as-is; connection will fail loudly if missing
|
|
pass
|
|
|
|
class Settings(BaseSettings):
|
|
"""Application configuration"""
|
|
|
|
# Database settings (shared mvp-postgres)
|
|
POSTGRES_HOST: str = os.getenv("POSTGRES_HOST", "mvp-postgres")
|
|
POSTGRES_PORT: int = int(os.getenv("POSTGRES_PORT", "5432"))
|
|
POSTGRES_USER: str = os.getenv("POSTGRES_USER", "postgres")
|
|
POSTGRES_PASSWORD: str = os.getenv("POSTGRES_PASSWORD", "")
|
|
POSTGRES_DATABASE: str = os.getenv("POSTGRES_DATABASE", "motovaultpro")
|
|
|
|
# Redis settings (shared mvp-redis)
|
|
REDIS_HOST: str = os.getenv("REDIS_HOST", "mvp-redis")
|
|
REDIS_PORT: int = int(os.getenv("REDIS_PORT", "6379"))
|
|
REDIS_DB: int = int(os.getenv("REDIS_DB", "1")) # Use DB 1 to separate from backend
|
|
|
|
# Database connection pool settings
|
|
DATABASE_MIN_CONNECTIONS: int = int(os.getenv("DATABASE_MIN_CONNECTIONS", "5"))
|
|
DATABASE_MAX_CONNECTIONS: int = int(os.getenv("DATABASE_MAX_CONNECTIONS", "20"))
|
|
|
|
# Cache settings
|
|
CACHE_TTL: int = int(os.getenv("CACHE_TTL", "3600")) # 1 hour default
|
|
|
|
# Application settings
|
|
DEBUG: bool = os.getenv("DEBUG", "false").lower() == "true"
|
|
CORS_ORIGINS: List[str] = [
|
|
"http://localhost:3000",
|
|
"https://motovaultpro.com",
|
|
"http://localhost:3001"
|
|
]
|
|
|
|
class Config:
|
|
case_sensitive = True
|
|
|
|
def get_settings() -> Settings:
|
|
"""Get application settings"""
|
|
return Settings()
|