98 lines
2.5 KiB
YAML
98 lines
2.5 KiB
YAML
# Dev/prod stack. Worker reuses the api image with a different command.
|
|
# The ML service is intentionally a commented placeholder — it is optional
|
|
# (graceful degradation) and lands in a later phase.
|
|
|
|
services:
|
|
api:
|
|
build: .
|
|
command: uvicorn app.main:app --host 0.0.0.0 --port 8000
|
|
env_file: .env
|
|
environment:
|
|
DATABASE_URL: postgresql+asyncpg://mcma:mcma@db:5432/mcma
|
|
REDIS_URL: redis://redis:6379/0
|
|
ports:
|
|
- "8000:8000"
|
|
volumes:
|
|
- media:/data/media
|
|
- transcode_cache:/data/transcode-cache
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://localhost:8000/health').status==200 else 1)"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
retries: 3
|
|
restart: unless-stopped
|
|
|
|
worker:
|
|
build: .
|
|
command: arq app.workers.arq_worker.WorkerSettings
|
|
env_file: .env
|
|
environment:
|
|
DATABASE_URL: postgresql+asyncpg://mcma:mcma@db:5432/mcma
|
|
REDIS_URL: redis://redis:6379/0
|
|
volumes:
|
|
- media:/data/media
|
|
- transcode_cache:/data/transcode-cache
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
restart: unless-stopped
|
|
|
|
db:
|
|
image: postgres:16-alpine
|
|
environment:
|
|
POSTGRES_USER: mcma
|
|
POSTGRES_PASSWORD: mcma
|
|
POSTGRES_DB: mcma
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U mcma"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
restart: unless-stopped
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
command: redis-server --save 60 1 --loglevel warning
|
|
volumes:
|
|
- redisdata:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
restart: unless-stopped
|
|
|
|
# Reverse proxy + auto-HTTPS (enable on prod with a real domain).
|
|
# caddy:
|
|
# image: caddy:2-alpine
|
|
# ports: ["80:80", "443:443"]
|
|
# volumes:
|
|
# - ./Caddyfile:/etc/caddy/Caddyfile
|
|
# - caddy_data:/data
|
|
# depends_on: [api]
|
|
# restart: unless-stopped
|
|
|
|
# ML recommendation service — OPTIONAL, added in a later phase.
|
|
# The backend must run fully without it (set ML_SERVICE_URL to enable).
|
|
# ml:
|
|
# image: mcma-ml:latest
|
|
# environment:
|
|
# MODEL_PATH: /models
|
|
# restart: unless-stopped
|
|
|
|
volumes:
|
|
pgdata:
|
|
redisdata:
|
|
media:
|
|
transcode_cache:
|
|
# caddy_data:
|