Files
wwjcloud/docker/docker-compose.yml

181 lines
4.8 KiB
YAML
Raw Permalink Normal View History

version: '3.8'
services:
# ========================================
# MySQL 数据库
# ========================================
mysql:
image: mysql:8.0
container_name: wwjcloud-mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: wwjcloud
MYSQL_DATABASE: wwjcloud
MYSQL_USER: wwjcloud
MYSQL_PASSWORD: wwjcloud
TZ: Asia/Shanghai
ports:
- "3306:3306"
volumes:
- wwjcloud_mysql_data:/var/lib/mysql
- ../../sql:/docker-entrypoint-initdb.d
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", "-pwwjcloud"]
interval: 10s
timeout: 5s
retries: 5
networks:
- wwjcloud-network
# ========================================
# Redis 缓存
# ========================================
redis:
image: redis:7-alpine
container_name: wwjcloud-redis
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- wwjcloud_redis_data:/data
command: redis-server --appendonly yes --requirepass redis123456
healthcheck:
test: ["CMD", "redis-cli", "-a", "redis123456", "ping"]
interval: 10s
timeout: 3s
retries: 5
networks:
- wwjcloud-network
# ========================================
# NestJS 后端服务
# ========================================
nestjs-backend:
build:
context: ..
dockerfile: docker/Dockerfile
container_name: wwjcloud-nestjs
restart: unless-stopped
ports:
- "3000:3000"
environment:
NODE_ENV: production
# App配置
APP_NAME: wwjcloud
APP_VERSION: 1.0.0
APP_PORT: 3000
APP_ENVIRONMENT: production
APP_TIMEZONE: Asia/Shanghai
APP_KEY: wwjcloud-super-secret-key-2024
APP_DEFAULT_LANGUAGE: zh_CN
APP_SUPPORTED_LOCALES: zh_CN,en_US
# 数据库配置
DB_HOST: mysql
DB_PORT: 3306
DB_USERNAME: wwjcloud
DB_PASSWORD: wwjcloud
DB_DATABASE: wwjcloud
DB_SYNC: false
DB_LOGGING: false
DB_CONN_LIMIT: 10
DB_ACQUIRE_TIMEOUT_MS: 60000
DB_QUERY_TIMEOUT_MS: 60000
DB_CACHE_DURATION_MS: 300000
DB_TIMEZONE: +08:00
DB_CHARSET: utf8mb4
# Redis配置
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_PASSWORD: redis123456
REDIS_DB: 0
REDIS_KEY_PREFIX: "wwjcloud:"
# JWT配置
JWT_SECRET: your-super-secret-jwt-key-change-in-production-32-chars
JWT_EXPIRES_IN: 7d
JWT_ALGORITHM: HS256
# Kafka配置
KAFKA_CLIENT_ID: wwjcloud-nestjs
KAFKA_BROKERS: kafka:9092
KAFKA_GROUP_ID: wwjcloud-group
KAFKA_TOPIC_PREFIX: wwjcloud
# 缓存配置
CACHE_TTL: 3600
CACHE_MAX_ITEMS: 1000
CACHE_PREFIX: "cache:"
# 日志配置
LOG_LEVEL: info
LOG_FORMAT: json
# 上传配置
UPLOAD_PATH: /app/uploads
UPLOAD_MAX_SIZE: 10485760
UPLOAD_ALLOWED_TYPES: image/jpeg,image/png,image/gif,application/pdf
# 限流配置
THROTTLE_TTL: 60
THROTTLE_LIMIT: 100
# 健康检查配置
STARTUP_HEALTH_CHECK: true
STARTUP_HEALTH_TIMEOUT_MS: 30000
# Swagger配置
SWAGGER_ENABLED: true
SWAGGER_TITLE: WWJCloud API
SWAGGER_DESCRIPTION: WWJCloud NestJS API Documentation
SWAGGER_VERSION: 1.0.0
SWAGGER_AUTH_ENABLED: true
SWAGGER_TOKEN: wwjcloud-swagger-token
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
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
networks:
- wwjcloud-network
# ========================================
# Admin 前端管理面板
# ========================================
admin-frontend:
build:
context: ../admin
dockerfile: Dockerfile
container_name: wwjcloud-admin
restart: unless-stopped
ports:
- "80:80"
depends_on:
nestjs-backend:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"]
interval: 30s
timeout: 3s
retries: 3
networks:
- wwjcloud-network
# ========================================
# 数据卷
# ========================================
volumes:
wwjcloud_mysql_data:
driver: local
wwjcloud_redis_data:
driver: local
# ========================================
# 网络
# ========================================
networks:
wwjcloud-network:
driver: bridge