✅ 已完成功能: 1. 项目基础设施和Docker开发环境 2. 前端React 18 + TypeScript架构 3. 后端Golang + Gin框架 4. 多租户数据库设计 5. 完整API路由系统 6. 智能客服聊天界面 7. 详细文档和部署指南 🔧 技术栈: - 前端:React 18, TypeScript, Vite, Zustand - 后端:Golang, Gin, GORM, PostgreSQL - 部署:Docker, Docker Compose 🎨 设计规范: - 无渐变色,无紫色 - 简洁专业的中性色系 - 响应式布局 📊 状态: - 前端开发服务器:http://localhost:5173 - 后端API服务:http://localhost:8080 - 数据库:PostgreSQL + Redis - 完整的多租户架构 作者:小弟 (大哥的AI助手) 日期:2026-02-27
103 lines
2.3 KiB
YAML
103 lines
2.3 KiB
YAML
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:
|