111 lines
3.2 KiB
YAML
111 lines
3.2 KiB
YAML
services:
|
|
# Redis message broker for Celery
|
|
redis:
|
|
image: redis:7-alpine
|
|
ports:
|
|
- "6379:6379"
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
restart: unless-stopped
|
|
|
|
# PostgreSQL database
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
environment:
|
|
POSTGRES_USER: ${DB_USER:-imagerepo}
|
|
POSTGRES_PASSWORD: ${DB_PASS:-postgres}
|
|
POSTGRES_DB: ${DB_NAME:-imagerepo}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-imagerepo}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
restart: unless-stopped
|
|
|
|
# Flask web application
|
|
web:
|
|
build: .
|
|
ports:
|
|
- "5000:5000"
|
|
environment:
|
|
- TZ=${TZ:-America/New_York}
|
|
- DB_USER=${DB_USER:-imagerepo}
|
|
- DB_PASS=${DB_PASS:-postgres}
|
|
- DB_HOST=postgres
|
|
- DB_PORT=5432
|
|
- DB_NAME=${DB_NAME:-imagerepo}
|
|
- CELERY_BROKER_URL=redis://redis:6379/0
|
|
- CELERY_RESULT_BACKEND=redis://redis:6379/0
|
|
volumes:
|
|
- ./imagerepo/images:/images
|
|
- ./import:/import
|
|
- ./migrations:/app/migrations # For dev
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
restart: unless-stopped
|
|
|
|
# Celery worker for processing import tasks (heavy processing)
|
|
# Handles: import, thumbnail, sidecar, default queues
|
|
worker:
|
|
build: .
|
|
command: celery -A app.celery_app:celery worker --loglevel=info -Q import,thumbnail,sidecar,default --concurrency=${CELERY_WORKER_CONCURRENCY:-2}
|
|
environment:
|
|
- TZ=${TZ:-America/New_York}
|
|
- DB_USER=${DB_USER:-imagerepo}
|
|
- DB_PASS=${DB_PASS:-postgres}
|
|
- DB_HOST=postgres
|
|
- DB_PORT=5432
|
|
- DB_NAME=${DB_NAME:-imagerepo}
|
|
- CELERY_BROKER_URL=redis://redis:6379/0
|
|
- CELERY_RESULT_BACKEND=redis://redis:6379/0
|
|
- CELERY_WORKER_CONCURRENCY=${CELERY_WORKER_CONCURRENCY:-2}
|
|
volumes:
|
|
- ./imagerepo/images:/images
|
|
- ./import:/import
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
restart: unless-stopped
|
|
|
|
# Celery scheduler: Beat (periodic tasks) + Worker (maintenance/scan queues)
|
|
# Handles: maintenance, scan queues + periodic task scheduling
|
|
# This ensures maintenance tasks aren't blocked by large import queues
|
|
scheduler:
|
|
build: .
|
|
command: celery -A app.celery_app:celery worker --beat --loglevel=info -Q maintenance,scan --concurrency=1
|
|
environment:
|
|
- TZ=${TZ:-America/New_York}
|
|
- DB_USER=${DB_USER:-imagerepo}
|
|
- DB_PASS=${DB_PASS:-postgres}
|
|
- DB_HOST=postgres
|
|
- DB_PORT=5432
|
|
- DB_NAME=${DB_NAME:-imagerepo}
|
|
- CELERY_BROKER_URL=redis://redis:6379/0
|
|
- CELERY_RESULT_BACKEND=redis://redis:6379/0
|
|
- IMPORT_EVERY_SECONDS=${IMPORT_EVERY_SECONDS:-28800}
|
|
volumes:
|
|
- ./imagerepo/images:/images
|
|
- ./import:/import
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
redis_data:
|
|
postgres_data:
|