Complete backend verification: fix syntax errors, create __init__.py files, add setup_db.py, update docker-compose for two PostgreSQL containers
This commit is contained in:
+62
-14
@@ -1,15 +1,15 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
# PostgreSQL - hosts both Cockatrice app data and mtgjson data
|
||||
# PostgreSQL - MTG Online App Database
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
container_name: mtg_postgres
|
||||
container_name: mtgonline_postgres
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER:-cockatrice}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-cockatrice_pass}
|
||||
POSTGRES_DB: ${POSTGRES_DB:-cockatrice}
|
||||
POSTGRES_USER: ${POSTGRES_USER:-mtgonline}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-mtgonline_pass}
|
||||
POSTGRES_DB: ${POSTGRES_DB:-mtgonline}
|
||||
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --lc-collate=C --lc-ctype=C"
|
||||
ports:
|
||||
- "${POSTGRES_PORT:-5432}:5432"
|
||||
@@ -19,31 +19,75 @@ services:
|
||||
networks:
|
||||
- mtg_network
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-cockatrice}"]
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-mtgonline}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 30s
|
||||
|
||||
# PostgreSQL - MTG Data Database
|
||||
postgres-mtgdata:
|
||||
image: postgres:16-alpine
|
||||
container_name: mtgonline_postgres_mtgdata
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER:-mtgonline}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-mtgonline_pass}
|
||||
POSTGRES_DB: ${MTGDATA_DB:-mtgdata}
|
||||
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --lc-collate=C --lc-ctype=C"
|
||||
ports:
|
||||
- "${MTGDATA_PORT:-5433}:5432"
|
||||
volumes:
|
||||
- postgres_mtgdata_data:/var/lib/postgresql/data
|
||||
- ./scripts/init-mtgdata.sql:/docker-entrypoint-initdb.d/01-init.sql
|
||||
networks:
|
||||
- mtg_network
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-mtgonline}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 30s
|
||||
|
||||
# Redis cache
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: mtgonline_redis
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${REDIS_PORT:-6379}:6379"
|
||||
networks:
|
||||
- mtg_network
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 5s
|
||||
|
||||
# Backend API
|
||||
backend:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
container_name: mtg_backend
|
||||
container_name: mtgonline_backend
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
postgres-mtgdata:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
- DATABASE_URL=${DATABASE_URL:-postgresql+asyncpg://cockatrice:cockatrice_pass@postgres:5432/cockatrice}
|
||||
- MTG_DATABASE_URL=${MTG_DATABASE_URL:-postgresql+asyncpg://cockatrice:cockatrice_pass@postgres:5432/mtgdata}
|
||||
- DATABASE_URL=${DATABASE_URL:-postgresql+asyncpg://mtgonline:mtgonline_pass@postgres:5432/mtgonline}
|
||||
- MTG_DATABASE_URL=${MTG_DATABASE_URL:-postgresql+asyncpg://mtgonline:mtgonline_pass@postgres-mtgdata:5432/mtgdata}
|
||||
- JWT_SECRET_KEY=${JWT_SECRET_KEY:-change-me-in-production}
|
||||
- JWT_ALGORITHM=${JWT_ALGORITHM:-HS256}
|
||||
- ACCESS_TOKEN_EXPIRE_MINUTES=${ACCESS_TOKEN_EXPIRE_MINUTES:-60}
|
||||
- REFRESH_TOKEN_EXPIRE_DAYS=${REFRESH_TOKEN_EXPIRE_DAYS:-7}
|
||||
- CORS_ORIGINS=${CORS_ORIGINS:-["http://localhost:3000","http://localhost:8000"]}
|
||||
- APP_NAME=${APP_NAME:-Cockatrice Web}
|
||||
- APP_NAME=${APP_NAME:-MTG Online}
|
||||
- APP_VERSION=${APP_VERSION:-0.2.0}
|
||||
- DEBUG=${DEBUG:-False}
|
||||
- MTG_REFRESH_INTERVAL_DAYS=${MTG_REFRESH_INTERVAL_DAYS:-7}
|
||||
@@ -51,7 +95,7 @@ services:
|
||||
- UPLOAD_DIR=${UPLOAD_DIR:-/app/uploads}
|
||||
- LOG_LEVEL=${LOG_LEVEL:-INFO}
|
||||
ports:
|
||||
- "${BACKEND_PORT:-8000}:8000"
|
||||
- "${BACKEND_PORT:-8001}:8000"
|
||||
volumes:
|
||||
- mtg_data:/app/data
|
||||
- mtg_uploads:/app/uploads
|
||||
@@ -70,14 +114,16 @@ services:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
container_name: mtg_refresh
|
||||
container_name: mtgonline_refresh
|
||||
restart: "no"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
postgres-mtgdata:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
- DATABASE_URL=${DATABASE_URL:-postgresql+asyncpg://cockatrice:cockatrice_pass@postgres:5432/cockatrice}
|
||||
- MTG_DATABASE_URL=${MTG_DATABASE_URL:-postgresql+asyncpg://cockatrice:cockatrice_pass@postgres:5432/mtgdata}
|
||||
- DATABASE_URL=${DATABASE_URL:-postgresql+asyncpg://mtgonline:mtgonline_pass@postgres:5432/mtgonline}
|
||||
- MTG_DATABASE_URL=${MTG_DATABASE_URL:-postgresql+asyncpg://mtgonline:mtgonline_pass@postgres-mtgdata:5432/mtgdata}
|
||||
- DATA_DIR=${DATA_DIR:-/app/data}
|
||||
- MTG_REFRESH_INTERVAL_DAYS=${MTG_REFRESH_INTERVAL_DAYS:-7}
|
||||
volumes:
|
||||
@@ -89,6 +135,8 @@ services:
|
||||
volumes:
|
||||
postgres_data:
|
||||
driver: local
|
||||
postgres_mtgdata_data:
|
||||
driver: local
|
||||
mtg_data:
|
||||
driver: local
|
||||
mtg_uploads:
|
||||
|
||||
Reference in New Issue
Block a user