# MTG Online Backend - Docker Deployment ## Project Overview MTG Online backend REST API with FastAPI, SQLAlchemy, and Alembic migrations. Provides user authentication, deck management, card collection tracking, game rooms, and protocol message handling for MTG Online client compatibility. ## Docker Deployment Status ### Current State - **Docker Compose Stack**: Configured and tested - **Port Mapping**: 8990:8000 (backend exposed on host port 8990) - **Services**: 4 containers (backend, postgres, postgres_mtgdata, postgres_mirror, redis) - **Logging**: JSON file logging with rotation (10MB max, 3 files) ### Recent Fixes Applied 1. **Database URL Fix**: Updated `.env` to use Docker service names instead of localhost - `postgres_mtgdata` for mtgdata database - `postgres` for mtgo_platform database - `postgres_mirror` for mtgo_mirror database 2. **Docker Build**: Successfully built backend image 3. **Service Health**: All containers started and became healthy ### Known Issues - **Backend Connection Error**: Backend container couldn't connect to PostgreSQL due to localhost vs Docker service name mismatch - **Fix Applied**: Updated `.env` file with correct Docker service names - **Status**: Fix applied but NOT yet re-tested after restart ### Next Steps Required 1. Restart Docker containers with updated `.env` 2. Verify backend can connect to all three PostgreSQL databases 3. Test health endpoint on port 8990 4. Test authentication and CRUD operations 5. Verify logging output ## Architecture - **Primary Database**: mtgo_platform (user data, decks, cards) - **MTG Data Database**: mtgdata (canonical card data) - **Mirror Database**: mtgo_mirror (fast deckbuilding queries) - **Cache**: Redis for session/cache management - **Async Driver**: asyncpg for async SQLAlchemy support ## Commands ```bash # Start stack cd /home/wall-o/projects/mtgonline/backend docker compose up -d # View logs docker compose logs -f backend docker compose logs -f postgres # Stop stack docker compose down # Rebuild after changes docker compose up -d --build ``` ## API Access - **Health Check**: http://localhost:8990/health - **API Docs**: http://localhost:8990/docs - **Backend Port**: 8990 (mapped to container port 8000)