major-domo-v2/config.py
Cal Corum 5924249481 CLAUDE: Add comprehensive Docker deployment infrastructure
Implements production-ready Docker setup with multi-stage builds and
separate development/production configurations.

New Files:
- Dockerfile: Multi-stage build with Python 3.13
  * Builder stage: Compiles dependencies with build tools
  * Runtime stage: Minimal image (~150-200MB) with non-root user
  * Health checks and security hardening
- docker-compose.yml: Production config (pulls from Docker Hub)
  * Image: manticorum67/major-domo-discordapp:latest
  * Resource limits: 512MB RAM, 1 CPU
  * Volumes: /app/data (ro), /app/logs (rw)
- docker-compose.dev.yml: Development config (builds locally)
  * Higher resource limits: 1GB RAM, 2 CPU
  * DEBUG log level by default
- .dockerignore: Excludes unnecessary files from build context
- build-and-push.sh: Interactive build/push script for Docker Hub
- DOCKER.md: Comprehensive deployment guide (13K)
- BUILD_AND_PUSH.md: Docker Hub build/push guide (7.7K)

Configuration Updates:
- config.py: Updated sheets_credentials_path to /app/data location
- requirements.txt: Pinned all package versions for reproducibility
- .env.example: Added Docker-specific configuration

Key Features:
- Multi-stage build for optimized image size
- Non-root user (botuser, UID 1000) for security
- Separate dev/prod compose files
- Volume mounts for persistence (/app/data, /app/logs)
- Health checks and automatic restarts
- Resource limits and log rotation
- Docker Hub integration for production deployments

Docker Hub Repository: manticorum67/major-domo-discordapp

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-16 00:54:56 -05:00

61 lines
1.6 KiB
Python

"""
Configuration management for Discord Bot v2.0
"""
from pydantic_settings import BaseSettings, SettingsConfigDict
class BotConfig(BaseSettings):
"""Application configuration with environment variable support."""
# Discord settings
bot_token: str
guild_id: int
# Database API settings
api_token: str
db_url: str
# League settings
sba_season: int = 12
pd_season: int = 9
fa_lock_week: int = 14
sba_color: str = "a6ce39"
# Application settings
log_level: str = "INFO"
environment: str = "development"
testing: bool = False
# Google Sheets settings
sheets_credentials_path: str = "/app/data/major-domo-service-creds.json"
# Optional Redis caching settings
redis_url: str = "" # Empty string means no Redis caching
redis_cache_ttl: int = 300 # 5 minutes default TTL
model_config = SettingsConfigDict(
env_file=".env",
case_sensitive=False,
extra="ignore" # Ignore extra environment variables
)
@property
def is_development(self) -> bool:
"""Check if running in development mode."""
return self.environment.lower() == "development"
@property
def is_testing(self) -> bool:
"""Check if running in test mode."""
return self.testing
# Global configuration instance - lazily initialized to avoid import-time errors
_config = None
def get_config() -> BotConfig:
"""Get the global configuration instance."""
global _config
if _config is None:
_config = BotConfig() # type: ignore
return _config