106 lines
3.2 KiB
YAML
106 lines
3.2 KiB
YAML
services:
|
|
# ─── PostgreSQL ───────────────────────────────────────────
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
container_name: iaai-postgres
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_USER: iaai
|
|
POSTGRES_PASSWORD: iaai
|
|
POSTGRES_DB: iaai_scraper
|
|
ports:
|
|
- "5432:5432"
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U iaai -d iaai_scraper"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 5
|
|
|
|
# ─── Redis (Celery broker) ────────────────────────────────
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: iaai-redis
|
|
restart: unless-stopped
|
|
ports:
|
|
- "6379:6379"
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 5
|
|
|
|
# ─── FastAPI ──────────────────────────────────────────────
|
|
api:
|
|
build: .
|
|
container_name: iaai-api
|
|
restart: unless-stopped
|
|
env_file:
|
|
- path: .env
|
|
required: false
|
|
environment:
|
|
IAAI_DATABASE_URL: postgresql+psycopg2://iaai:iaai@postgres:5432/iaai_scraper
|
|
IAAI_REDIS_URL: redis://redis:6379/0
|
|
CELERY_BROKER_URL: redis://redis:6379/0
|
|
CELERY_RESULT_BACKEND: redis://redis:6379/0
|
|
ports:
|
|
- "8000:8000"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
command: >
|
|
uvicorn iaai_scraper.api.app:app
|
|
--host 0.0.0.0 --port 8000 --workers 2
|
|
|
|
# ─── Celery Worker ────────────────────────────────────────
|
|
worker:
|
|
build: .
|
|
container_name: iaai-worker
|
|
restart: unless-stopped
|
|
env_file:
|
|
- path: .env
|
|
required: false
|
|
environment:
|
|
IAAI_DATABASE_URL: postgresql+psycopg2://iaai:iaai@postgres:5432/iaai_scraper
|
|
IAAI_REDIS_URL: redis://redis:6379/0
|
|
CELERY_BROKER_URL: redis://redis:6379/0
|
|
CELERY_RESULT_BACKEND: redis://redis:6379/0
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
stop_grace_period: 60s
|
|
command: >
|
|
celery -A iaai_scraper.worker.celery_app worker
|
|
--loglevel=info --concurrency=1 --pool=prefork
|
|
-Q scraping --without-heartbeat
|
|
|
|
# ─── Celery Beat (периодический планировщик) ──────────────
|
|
beat:
|
|
build: .
|
|
container_name: iaai-beat
|
|
restart: unless-stopped
|
|
env_file:
|
|
- path: .env
|
|
required: false
|
|
environment:
|
|
IAAI_DATABASE_URL: postgresql+psycopg2://iaai:iaai@postgres:5432/iaai_scraper
|
|
IAAI_REDIS_URL: redis://redis:6379/0
|
|
CELERY_BROKER_URL: redis://redis:6379/0
|
|
CELERY_RESULT_BACKEND: redis://redis:6379/0
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
command: >
|
|
celery -A iaai_scraper.worker.celery_app beat
|
|
--loglevel=info
|
|
|
|
volumes:
|
|
pgdata:
|