x-app-env-files: &app-env-files - path: .env required: true services: db: image: postgres:16-alpine environment: POSTGRES_USER: ${POSTGRES_USER:-company_ai} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-} POSTGRES_DB: ${POSTGRES_DB:-company_ai} volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] interval: 10s timeout: 5s retries: 5 restart: unless-stopped redis: image: redis:7-alpine volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 5s retries: 5 restart: unless-stopped migrate: build: . env_file: *app-env-files environment: APP_ENV: production DATABASE_URL: "${COMPOSE_DATABASE_URL:-postgresql+psycopg://${POSTGRES_USER:-company_ai}:${POSTGRES_PASSWORD:-}@db:5432/${POSTGRES_DB:-company_ai}}" REDIS_URL: redis://redis:6379/0 command: ["alembic", "upgrade", "head"] depends_on: db: condition: service_healthy restart: "no" api: build: . env_file: *app-env-files environment: APP_ENV: production DATABASE_URL: "${COMPOSE_DATABASE_URL:-postgresql+psycopg://${POSTGRES_USER:-company_ai}:${POSTGRES_PASSWORD:-}@db:5432/${POSTGRES_DB:-company_ai}}" REDIS_URL: redis://redis:6379/0 SCHEDULER_ENABLED: "false" TASK_QUEUE_ENABLED: "true" ports: - "8010:8010" depends_on: db: condition: service_healthy redis: condition: service_healthy migrate: condition: service_completed_successfully healthcheck: test: [ "CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8010/api/v1/health/ready', timeout=3).read()", ] interval: 10s timeout: 5s retries: 5 start_period: 30s restart: unless-stopped worker: build: . env_file: *app-env-files environment: APP_ENV: production DATABASE_URL: "${COMPOSE_DATABASE_URL:-postgresql+psycopg://${POSTGRES_USER:-company_ai}:${POSTGRES_PASSWORD:-}@db:5432/${POSTGRES_DB:-company_ai}}" REDIS_URL: redis://redis:6379/0 TASK_QUEUE_ENABLED: "true" SCHEDULER_ENABLED: "false" command: ["celery", "-A", "app.tasks:celery_app", "worker", "--loglevel=info"] depends_on: db: condition: service_healthy redis: condition: service_healthy migrate: condition: service_completed_successfully restart: unless-stopped scheduler: build: . env_file: *app-env-files environment: APP_ENV: production DATABASE_URL: "${COMPOSE_DATABASE_URL:-postgresql+psycopg://${POSTGRES_USER:-company_ai}:${POSTGRES_PASSWORD:-}@db:5432/${POSTGRES_DB:-company_ai}}" REDIS_URL: redis://redis:6379/0 SCHEDULER_ENABLED: "true" TASK_QUEUE_ENABLED: "true" command: ["python", "-m", "app.tools.run_scheduler"] depends_on: db: condition: service_healthy redis: condition: service_healthy migrate: condition: service_completed_successfully restart: unless-stopped feishu-events: build: . profiles: ["long-connection"] env_file: *app-env-files environment: APP_ENV: production DATABASE_URL: "${COMPOSE_DATABASE_URL:-postgresql+psycopg://${POSTGRES_USER:-company_ai}:${POSTGRES_PASSWORD:-}@db:5432/${POSTGRES_DB:-company_ai}}" REDIS_URL: redis://redis:6379/0 FEISHU_EVENT_TRANSPORT: long_connection SCHEDULER_ENABLED: "false" TASK_QUEUE_ENABLED: "true" command: ["python", "-m", "app.modules.feishu.long_connection"] depends_on: db: condition: service_healthy redis: condition: service_healthy migrate: condition: service_completed_successfully restart: unless-stopped volumes: postgres_data: redis_data: