Files
kami_apple_exchage/deploy/docker-compose.yml
danial 00ab9f48fc refactor(data): 重构数据目录结构并优化相关配置
- 移除 screenshot 相关代码和配置
- 修改 SNAPSHOT_DIR 路径为复数形式
- 更新 Dockerfile 和 docker-compose 文件中的数据目录结构
- 优化 playwright_service 中的等待逻辑
- 修改异常日志输出,使用 traceback 提供更详细的信息
2025-09-19 19:11:39 +08:00

158 lines
3.9 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Apple Gift Card Exchange Platform - Combined Docker Compose
# 包含前端和后端的完整部署配置
services:
# ===== 前端服务 =====
frontend:
build:
context: ../frontend
dockerfile: Dockerfile
container_name: apple-exchange-frontend
ports:
- "3000:8080"
environment:
- NODE_ENV=production
- NEXT_PUBLIC_ENV=production
networks:
- app-network
depends_on:
- api
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# ===== 后端 API 服务 =====
api:
build:
context: ../backend
dockerfile: Dockerfile
container_name: apple-exchange-api
environment:
- SERVICE_TYPE=api
- ENVIRONMENT=production
- DATABASE_URL=postgresql+asyncpg://postgres:password@db:5432/apple_exchange
- REDIS_URL=redis://redis:6379/0
- WORKERS=4
- LOG_DIR=/app/logs
volumes:
- logs:/app/logs
- data:/app/data
networks:
- app-network
depends_on:
- db
- redis
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/health/liveness"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# ===== Celery Worker 服务 =====
worker:
build:
context: ../backend
dockerfile: Dockerfile.worker
container_name: apple-exchange-worker
environment:
- SERVICE_TYPE=worker
- ENVIRONMENT=production
- DATABASE_URL=postgresql+asyncpg://postgres:password@db:5432/apple_exchange
- REDIS_URL=redis://redis:6379/0
- WORKER_MAX_CONCURRENT_TASKS=2
- LOG_DIR=/app/logs
- PLAYWRIGHT_BROWSERS_PATH=/app/data/playwright-browsers
volumes:
- logs:/app/logs
- data:/app/data
- playwright_browsers:/app/data/playwright-browsers
networks:
- app-network
depends_on:
- db
- redis
healthcheck:
test: ["CMD", "python", "-c", "from app.core.arq_worker import get_arq_worker; worker = get_arq_worker(); print('Arq worker healthy')"]
interval: 60s
timeout: 30s
retries: 3
start_period: 60s
# ===== Arq 任务调度监控(可选)=====
# 注Arq 已经内置了任务调度功能如果需要Web监控界面
# 可以考虑部署 Arq Dashboard 或其他监控工具
# ===== PostgreSQL 数据库 =====
db:
image: postgres:17-alpine
container_name: apple-exchange-db
environment:
- POSTGRES_DB=apple_exchange
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5444:5432"
networks:
- app-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
# ===== Redis 缓存和消息代理 =====
redis:
image: redis:7-alpine
container_name: apple-exchange-redis
volumes:
- redis_data:/data
ports:
- "6379:6379"
networks:
- app-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
# ===== 可选:任务监控服务 =====
# 注如果需要Web监控界面可以考虑部署 Arq Dashboard 或其他监控工具
# ===== 数据卷 =====
volumes:
postgres_data:
driver: local
name: apple-exchange-postgres-data
redis_data:
driver: local
name: apple-exchange-redis-data
shared_storage:
driver: local
name: apple-exchange-shared-storage
playwright_browsers:
driver: local
name: apple-exchange-playwright-browsers
logs:
driver: local
name: apple-exchange-logs
data:
driver: local
name: apple-exchange-data
screenshots:
driver: local
name: apple-exchange-screenshots
# ===== 网络 =====
networks:
app-network:
driver: bridge
name: apple-exchange-network