Files
ljwx-health/docker-compose.prod.yml
2025-11-28 13:49:45 +08:00

213 lines
5.5 KiB
YAML

# LJWX 生产环境 Docker Compose 配置
# 使用本地 Registry 镜像部署
version: '3.8'
networks:
ljwx-network:
driver: bridge
volumes:
mysql_data:
driver: local
redis_data:
driver: local
services:
# ============================================
# 基础设施服务
# ============================================
# MySQL数据库 - 基于宿主机 test 数据库构建
ljwx-mysql:
image: localhost:15000/ljwx/ljwx-mysql:2.0.3
container_name: ljwx-mysql
environment:
- MYSQL_ROOT_PASSWORD=123456
- MYSQL_DATABASE=test
- TZ=Asia/Shanghai
volumes:
- mysql_data:/var/lib/mysql
ports:
- "3307:3306"
networks:
- ljwx-network
restart: unless-stopped
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p123456"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
# Redis缓存
ljwx-redis:
image: localhost:15000/ljwx/ljwx-redis:2.0.3
container_name: ljwx-redis
command: redis-server --requirepass 123456
environment:
- TZ=Asia/Shanghai
volumes:
- redis_data:/data
ports:
- "6379:6379"
networks:
- ljwx-network
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "-a", "123456", "ping"]
interval: 10s
timeout: 3s
retries: 5
start_period: 10s
# ============================================
# 业务应用服务
# ============================================
# 后端服务 - ljwx-boot
ljwx-boot:
image: localhost:15000/ljwx/ljwx-boot:2.0.3
container_name: ljwx-boot
environment:
# JVM 配置
- JAVA_OPTS=-Xms512m -Xmx1g -XX:+UseG1GC -XX:MaxGCPauseMillis=200
# Spring Boot 配置
- SPRING_PROFILES_ACTIVE=prod
# 数据库配置 - 连接容器内 MySQL test 数据库
- SPRING_DATASOURCE_URL=jdbc:mysql://ljwx-mysql:3306/test?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true&autoReconnect=true&failOverReadOnly=false&maxReconnects=3&initialTimeout=2&connectTimeout=60000&socketTimeout=60000
- SPRING_DATASOURCE_USERNAME=root
- SPRING_DATASOURCE_PASSWORD=123456
- SPRING_DATASOURCE_DRIVER_CLASS_NAME=com.mysql.cj.jdbc.Driver
# Redis 配置
- REDIS_HOST=ljwx-redis
- REDIS_PORT=6379
- REDIS_PASSWORD=123456
- SPRING_REDIS_HOST=ljwx-redis
- SPRING_REDIS_PORT=6379
- SPRING_REDIS_PASSWORD=123456
# 时区配置
- TZ=Asia/Shanghai
ports:
- "9998:9998"
depends_on:
ljwx-mysql:
condition: service_healthy
ljwx-redis:
condition: service_healthy
networks:
- ljwx-network
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "netstat -an | grep 9998 || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 120s
# 大屏服务 - ljwx-bigscreen
ljwx-bigscreen:
image: localhost:15000/ljwx/ljwx-bigscreen:2.0.3
container_name: ljwx-bigscreen
environment:
# 数据库配置 - 连接容器内 MySQL test 数据库
- MYSQL_HOST=ljwx-mysql
- MYSQL_PORT=3306
- MYSQL_DATABASE=test
- MYSQL_USER=root
- MYSQL_PASSWORD=123456
# Redis 配置
- REDIS_HOST=ljwx-redis
- REDIS_PORT=6379
- REDIS_PASSWORD=123456
# 后端API配置
- API_BASE_URL=http://ljwx-boot:9998
- BACKEND_URL=http://ljwx-boot:9998
# 时区配置
- TZ=Asia/Shanghai
ports:
- "8000:5225"
depends_on:
ljwx-mysql:
condition: service_healthy
ljwx-boot:
condition: service_healthy
ljwx-redis:
condition: service_healthy
networks:
- ljwx-network
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "netstat -an | grep 5225 || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
# 前端管理界面 - ljwx-admin
ljwx-admin:
image: localhost:15000/ljwx/ljwx-admin:2.0.3
container_name: ljwx-admin
environment:
- API_BASE_URL=http://ljwx-boot:9998
- TZ=Asia/Shanghai
ports:
- "8080:80"
depends_on:
ljwx-boot:
condition: service_healthy
networks:
- ljwx-network
restart: unless-stopped
# ============================================
# 使用说明
# ============================================
#
# 前提条件:
# 1. 已使用 build-and-push.sh 构建并推送镜像到本地 Registry
# 2. 本地 Registry 运行在 localhost:15000
#
# 启动服务:
# # 启动所有服务
# docker-compose -f docker-compose.prod.yml up -d
#
# # 仅启动基础设施
# docker-compose -f docker-compose.prod.yml up -d ljwx-mysql ljwx-redis
#
# # 启动应用服务
# docker-compose -f docker-compose.prod.yml up -d ljwx-boot ljwx-bigscreen ljwx-admin
#
# 查看服务:
# docker-compose -f docker-compose.prod.yml ps
# docker-compose -f docker-compose.prod.yml logs -f ljwx-boot
#
# 停止服务:
# docker-compose -f docker-compose.prod.yml down
#
# 重启服务:
# docker-compose -f docker-compose.prod.yml restart ljwx-boot
#
# ============================================
# 服务访问地址
# ============================================
#
# 业务应用:
# - 后端API: http://localhost:9998
# - 管理界面: http://localhost:80
# - 大屏服务: http://localhost:8000
#
# 基础设施:
# - MySQL: localhost:3306 (root/123456)
# - Redis: localhost:6379
#
# 健康检查:
# - Boot: http://localhost:9998/actuator/health
#