x-postgres-credentials: &postgres_credentials POSTGRES_USER: ${POSTGRES_USER:-postgres} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password} POSTGRES_DB: ${POSTGRES_DB:-chatdify} x-app-common: &app_common build: . env_file: - .env environment: <<: *postgres_credentials DB_HOST: ${DB_HOST:-postgres} DB_PORT: ${DB_PORT:-5432} volumes: - ./app:/app/app services: api: <<: *app_common command: fastapi dev --host 0.0.0.0 --port 8000 restart: always ports: - "127.0.0.1:8000:8000" depends_on: postgres: condition: service_healthy worker: condition: service_started redis: condition: service_healthy healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/health"] interval: 1200s timeout: 5s retries: 5 worker: <<: *app_common command: celery -A app.tasks worker --loglevel=info --concurrency=4 --pool=prefork restart: always depends_on: redis: condition: service_healthy postgres: image: postgres:16 restart: always healthcheck: test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER:-postgres}"] interval: 5s timeout: 5s retries: 5 volumes: - postgres_data:/var/lib/postgresql/data environment: <<: *postgres_credentials ports: - "127.0.0.1:5433:5432" redis: image: redis:6-alpine restart: always healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 3s retries: 5 volumes: - redis_data:/data ports: - "127.0.0.1:6380:6379" volumes: postgres_data: redis_data: