- 基于 NestJS + TypeScript + MySQL + Redis 架构 - 完整的模块化设计(认证、用户、小组、游戏、预约等) - JWT 认证和 RBAC 权限控制系统 - Docker 容器化部署支持 - 添加 CLAUDE.md 项目开发指南 - 配置 .gitignore 忽略文件 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
76 lines
1.8 KiB
YAML
76 lines
1.8 KiB
YAML
version: '3.8'
|
||
|
||
services:
|
||
# MySQL数据库
|
||
mysql:
|
||
image: mysql:8.0
|
||
container_name: gamegroup-mysql-prod
|
||
environment:
|
||
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
|
||
MYSQL_DATABASE: ${DB_DATABASE}
|
||
MYSQL_USER: ${DB_USERNAME}
|
||
MYSQL_PASSWORD: ${DB_PASSWORD}
|
||
volumes:
|
||
- mysql-data:/var/lib/mysql
|
||
- ./backups:/backups
|
||
networks:
|
||
- gamegroup-network
|
||
restart: unless-stopped
|
||
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=200
|
||
|
||
# 后端应用
|
||
backend:
|
||
build:
|
||
context: .
|
||
dockerfile: Dockerfile
|
||
target: production
|
||
container_name: gamegroup-backend-prod
|
||
environment:
|
||
NODE_ENV: production
|
||
DB_HOST: mysql
|
||
DB_PORT: 3306
|
||
DB_USERNAME: ${DB_USERNAME}
|
||
DB_PASSWORD: ${DB_PASSWORD}
|
||
DB_DATABASE: ${DB_DATABASE}
|
||
DB_SYNCHRONIZE: "false"
|
||
DB_LOGGING: "false"
|
||
JWT_SECRET: ${JWT_SECRET}
|
||
JWT_EXPIRES_IN: ${JWT_EXPIRES_IN}
|
||
CORS_ORIGIN: ${CORS_ORIGIN}
|
||
ports:
|
||
- "3000:3000"
|
||
depends_on:
|
||
- mysql
|
||
networks:
|
||
- gamegroup-network
|
||
restart: unless-stopped
|
||
healthcheck:
|
||
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
|
||
interval: 30s
|
||
timeout: 10s
|
||
retries: 3
|
||
start_period: 40s
|
||
|
||
# Nginx反向代理(可选)
|
||
nginx:
|
||
image: nginx:alpine
|
||
container_name: gamegroup-nginx
|
||
ports:
|
||
- "80:80"
|
||
- "443:443"
|
||
volumes:
|
||
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||
- ./ssl:/etc/nginx/ssl:ro
|
||
depends_on:
|
||
- backend
|
||
networks:
|
||
- gamegroup-network
|
||
restart: unless-stopped
|
||
|
||
volumes:
|
||
mysql-data:
|
||
|
||
networks:
|
||
gamegroup-network:
|
||
driver: bridge
|