mantimon-tcg/backend/docker-compose.yml
Cal Corum 50684a1b11 Add database infrastructure with SQLAlchemy models and test suite
Phase 1 Database Implementation (DB-001 through DB-012):

Models:
- User: OAuth support (Google/Discord), premium subscriptions
- Collection: Card ownership with CardSource enum
- Deck: JSONB cards/energy_cards, validation state
- CampaignProgress: One-to-one with User, medals/NPCs as JSONB
- ActiveGame: In-progress games with GameType enum
- GameHistory: Completed games with EndReason enum, replay data

Infrastructure:
- Alembic migrations with sync psycopg2 (avoids async issues)
- Docker Compose for Postgres (5433) and Redis (6380)
- App config with Pydantic settings
- Redis client helper

Test Infrastructure:
- 68 database tests (47 model + 21 relationship)
- Async factory pattern for test data creation
- Sync TRUNCATE cleanup (solves pytest-asyncio event loop mismatch)
- Uses dev containers instead of testcontainers for reliability

Key technical decisions:
- passive_deletes=True for ON DELETE SET NULL relationships
- NullPool for test sessions (no connection reuse)
- expire_on_commit=False with manual expire() for relationship tests
2026-01-27 10:17:30 -06:00

50 lines
1.2 KiB
YAML

# Docker Compose for Mantimon TCG local development
#
# Usage:
# docker-compose up -d # Start services in background
# docker-compose down # Stop services
# docker-compose logs -f # Follow logs
# docker-compose ps # Check status
#
# Services:
# - PostgreSQL 15 (port 5433 -> 5432)
# - Redis 7 (port 6380 -> 6379)
#
# Note: Non-standard host ports to avoid conflicts with other projects
services:
postgres:
image: postgres:15-alpine
container_name: mantimon-postgres
environment:
POSTGRES_USER: mantimon
POSTGRES_PASSWORD: mantimon
POSTGRES_DB: mantimon
ports:
- "5433:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U mantimon -d mantimon"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
redis:
image: redis:7-alpine
container_name: mantimon-redis
command: redis-server --appendonly no --maxmemory 100mb --maxmemory-policy allkeys-lru
ports:
- "6380:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
volumes:
postgres_data:
name: mantimon_postgres_data