version: "3.8" # ============================================================================= # 生产部署配置 # ============================================================================= # 启动:docker compose up -d # agentkit 容器内通过 service name (redis/postgres) 连接,不暴露中间件端口 # ============================================================================= services: agentkit: build: . command: serve --host 0.0.0.0 --port 8001 ports: - "8001:8001" env_file: .env environment: # 容器间通信:使用 service name,不依赖宿主机端口 - REDIS_URL=redis://redis:6379/0 - DATABASE_URL=postgresql+asyncpg://agentkit:agentkit@postgres:5432/agentkit - AGENTKIT_BUS_BACKEND=redis - AGENTKIT_SESSION_BACKEND=redis - AGENTKIT_TASK_STORE_BACKEND=redis depends_on: redis: condition: service_healthy postgres: condition: service_healthy healthcheck: test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8001/api/v1/health')"] interval: 30s timeout: 10s start_period: 30s retries: 3 restart: unless-stopped redis: image: redis:7-alpine # 生产模式不暴露端口到宿主机,仅容器间可达 expose: - "6379" volumes: - redisdata:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 5s retries: 5 restart: unless-stopped postgres: image: pgvector/pgvector:pg15 # 生产模式不暴露端口到宿主机,仅容器间可达 expose: - "5432" environment: POSTGRES_USER: agentkit POSTGRES_PASSWORD: agentkit POSTGRES_DB: agentkit volumes: - pgdata:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U agentkit"] interval: 10s timeout: 5s retries: 5 restart: unless-stopped volumes: redisdata: pgdata: