Files
wecome-middleware/docker-compose.yml
xudw 034d425b21 初始提交: WeCom Middleware项目基础结构
包含以下内容:
1. Spring Boot后端项目结构
2. Vue.js前端项目结构
3. Docker Compose部署配置
4. MySQL数据库初始化脚本
5. Redis缓存配置
6. Nginx反向代理配置
7. 完整的项目文档

技术栈:
- 后端: Spring Boot 2.7.18 + Java 11 + MyBatis Plus
- 前端: Vue.js 3 + TypeScript + Element Plus
- 数据库: MySQL 8.0 + Redis 7
- 部署: Docker Compose + Nginx

已部署服务:
- 后端API: http://localhost:18080
- 前端界面: http://localhost:13000
- 数据库管理: http://localhost:18081
- MySQL: localhost:13306
- Redis: localhost:16379
2026-03-09 12:39:09 +08:00

118 lines
3.2 KiB
YAML

version: '3.8'
services:
# MySQL数据库
mysql:
image: mysql:8.0
container_name: wecom-mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: wecom123456
MYSQL_DATABASE: wecom_middleware
MYSQL_USER: wecom
MYSQL_PASSWORD: wecom123456
ports:
- "13306:3306" # 修改端口避免冲突
volumes:
- mysql_data:/var/lib/mysql
- ./scripts/init.sql:/docker-entrypoint-initdb.d/init.sql
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --default-authentication-plugin=mysql_native_password
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-pwecom123456"]
interval: 10s
timeout: 5s
retries: 5
# Redis缓存
redis:
image: redis:7-alpine
container_name: wecom-redis
restart: unless-stopped
ports:
- "16379:6379" # 修改端口避免冲突
volumes:
- redis_data:/data
command: redis-server --appendonly yes --requirepass redis123456
healthcheck:
test: ["CMD", "redis-cli", "-a", "redis123456", "ping"]
interval: 10s
timeout: 5s
retries: 5
# 后端Spring Boot应用
backend:
build:
context: .
dockerfile: docker/Dockerfile.backend
container_name: wecom-backend
restart: unless-stopped
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
ports:
- "18080:8080" # 修改端口避免冲突
environment:
- SPRING_PROFILES_ACTIVE=dev
- SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/wecom_middleware?useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
- SPRING_DATASOURCE_USERNAME=wecom
- SPRING_DATASOURCE_PASSWORD=wecom123456
- SPRING_REDIS_HOST=redis
- SPRING_REDIS_PORT=6379
- SPRING_REDIS_PASSWORD=redis123456
- WECOM_BOT_ID=${WECOM_BOT_ID:-your_bot_id}
- WECOM_BOT_SECRET=${WECOM_BOT_SECRET:-your_bot_secret}
- OPENCLAW_GATEWAY_URL=${OPENCLAW_GATEWAY_URL:-ws://host.docker.internal:18789}
- OPENCLAW_GATEWAY_TOKEN=${OPENCLAW_GATEWAY_TOKEN:-your_openclaw_token}
volumes:
- ./logs/backend:/app/logs
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/api/system/health"]
interval: 30s
timeout: 10s
retries: 3
# 前端Vue应用
frontend:
build:
context: .
dockerfile: docker/Dockerfile.frontend
container_name: wecom-frontend
restart: unless-stopped
depends_on:
- backend
ports:
- "13000:80" # 修改端口避免冲突
volumes:
- ./logs/nginx:/var/log/nginx
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80"]
interval: 30s
timeout: 10s
retries: 3
# 监控工具(可选)
adminer:
image: adminer
container_name: wecom-adminer
restart: unless-stopped
depends_on:
- mysql
ports:
- "18081:8080" # 修改端口避免冲突
environment:
ADMINER_DEFAULT_SERVER: mysql
volumes:
mysql_data:
driver: local
redis_data:
driver: local
networks:
default:
name: wecom-network