Files
mtgonline/backend/docker-compose.yml
T
akadmin 7235c49cb4 Fix database connection: Correct environment variable names for Docker deployment
- Changed MTG_PLATFORM_DATABASE_URL to DATABASE_URL to match settings.py
- Removed MTG_MIRROR_DATABASE_URL (mirror uses primary database)
- Reordered environment variables for clarity
- Fixed hostname references to match docker-compose service names
2026-08-25 03:19:58 +00:00

232 lines
5.6 KiB
YAML

services:
backend:
build:
context: .
dockerfile: Dockerfile
container_name: mtgonline_backend
hostname: mtgonline_backend
ports:
- "8990:8000"
environment:
- DATABASE_URL=postgresql+asyncpg://postgres:postgres@postgres_platform:5432/mtgo_platform
- MTG_DATABASE_URL=postgresql+asyncpg://postgres:postgres@postgres_mtgdata:5432/mtgdata
- REDIS_URL=redis://redis:6379/0
- MTG_BACKEND_URL=http://localhost:8990
- MTGJSON_DATA_DIR=/app/data
- MTGJSON_URL=https://mtgjson.com/api/v5/
- MTG_INTERACTION_MIN_CONFIDENCE=0.5
- MTG_INTERACTION_BATCH_SIZE=1000
- MTG_INTERACTION_REVIEW_QUEUE=true
- MTG_LOG_LEVEL=INFO
- MTG_LOG_FORMAT=text
- SECRET_KEY=change-this-secret-key-in-production
- JWT_SECRET_KEY=change-this-jwt-secret-key-in-production
- DATA_DIR=/app/data
- UPLOAD_DIR=/app/uploads
volumes:
- mtg_data:/app/data
- mtg_uploads:/app/uploads
- mtg_logs:/app/logs
depends_on:
postgres_platform:
condition: service_healthy
postgres_mtgdata:
condition: service_healthy
postgres_mirror:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 5s
retries: 3
start_period: 40s
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "5"
tag: "{{.Name}}"
networks:
mtgonline_network:
aliases:
- backend
- mtgonline-api
restart: unless-stopped
deploy:
resources:
limits:
memory: 1G
cpus: "1.0"
reservations:
memory: 512M
cpus: "0.5"
postgres_platform:
image: postgres:16-alpine
container_name: mtgonline_postgres_platform
hostname: postgres_platform
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=mtgo_platform
volumes:
- postgres_platform_data:/var/lib/postgresql/data
- ./scripts/init_platform.sql:/docker-entrypoint-initdb.d/01-init.sql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d mtgo_platform"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "5"
tag: "{{.Name}}"
networks:
mtgonline_network:
aliases:
- postgres-platform
- platform-db
restart: unless-stopped
deploy:
resources:
limits:
memory: 512M
cpus: "0.5"
reservations:
memory: 256M
cpus: "0.25"
postgres_mtgdata:
image: postgres:16-alpine
container_name: mtgonline_postgres_mtgdata
hostname: postgres_mtgdata
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=mtgdata
volumes:
- postgres_mtgdata_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d mtgdata"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "5"
tag: "{{.Name}}"
networks:
mtgonline_network:
aliases:
- postgres-mtgdata
- mtgdata-db
restart: unless-stopped
deploy:
resources:
limits:
memory: 512M
cpus: "0.5"
reservations:
memory: 256M
cpus: "0.25"
postgres_mirror:
image: postgres:16-alpine
container_name: mtgonline_postgres_mirror
hostname: postgres_mirror
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=mtgo_mirror
volumes:
- postgres_mirror_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d mtgo_mirror"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "5"
tag: "{{.Name}}"
networks:
mtgonline_network:
aliases:
- postgres-mirror
- mirror-db
restart: unless-stopped
deploy:
resources:
limits:
memory: 512M
cpus: "0.5"
reservations:
memory: 256M
cpus: "0.25"
redis:
image: redis:7-alpine
container_name: mtgonline_redis
hostname: redis
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 5s
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "5"
tag: "{{.Name}}"
networks:
mtgonline_network:
aliases:
- redis
- cache
restart: unless-stopped
deploy:
resources:
limits:
memory: 512M
cpus: "0.5"
reservations:
memory: 256M
cpus: "0.25"
volumes:
postgres_platform_data:
driver: local
postgres_mtgdata_data:
driver: local
postgres_mirror_data:
driver: local
mtg_data:
driver: local
mtg_uploads:
driver: local
mtg_logs:
driver: local
redis_data:
driver: local
networks:
mtgonline_network:
driver: bridge
name: mtgonline_network