version: '3.8' services: # PostgreSQL数据库 postgres: image: postgres:15-alpine container_name: customer-service-db environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: customer_service ports: - "5432:5432" volumes: - postgres_data:/var/lib/postgresql/data - ./backend/migrations:/docker-entrypoint-initdb.d healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 10s timeout: 5s retries: 5 # Redis缓存 redis: image: redis:7-alpine container_name: customer-service-redis ports: - "6379:6379" volumes: - redis_data:/data command: redis-server --appendonly yes healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 5s retries: 5 # 后端服务 backend: build: context: ./backend dockerfile: Dockerfile.dev container_name: customer-service-backend ports: - "8080:8080" - "8081:8081" # WebSocket端口 environment: - SERVER_PORT=8080 - SERVER_MODE=debug - DB_HOST=postgres - DB_PORT=5432 - DB_USER=postgres - DB_PASSWORD=postgres - DB_NAME=customer_service - REDIS_HOST=redis - REDIS_PORT=6379 - JWT_SECRET=your-secret-key-change-in-production - AI_PROVIDER=openai - AI_API_KEY=${AI_API_KEY:-} - WS_PORT=8081 volumes: - ./backend:/app - go_modules:/go/pkg/mod depends_on: postgres: condition: service_healthy redis: condition: service_healthy restart: unless-stopped # 前端服务 frontend: build: context: ./frontend dockerfile: Dockerfile.dev container_name: customer-service-frontend ports: - "3000:3000" environment: - VITE_API_URL=http://localhost:8080 - VITE_WS_URL=ws://localhost:8081 volumes: - ./frontend:/app - /app/node_modules depends_on: - backend restart: unless-stopped # 管理界面(可选) adminer: image: adminer container_name: customer-service-adminer ports: - "8082:8080" depends_on: - postgres restart: unless-stopped volumes: postgres_data: redis_data: go_modules: