238 lines
6.3 KiB
YAML
238 lines
6.3 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
# MySQL数据库
|
|
mysql:
|
|
image: mysql:8.0
|
|
container_name: emotion-mysql
|
|
restart: unless-stopped
|
|
environment:
|
|
MYSQL_ROOT_PASSWORD: 123456
|
|
MYSQL_DATABASE: emotion_museum
|
|
MYSQL_USER: emotion
|
|
MYSQL_PASSWORD: emotion123
|
|
TZ: Asia/Shanghai
|
|
ports:
|
|
- "3306:3306"
|
|
volumes:
|
|
- mysql_data:/var/lib/mysql
|
|
- ./backend/mysql_emotion_museum_final.sql:/docker-entrypoint-initdb.d/init.sql
|
|
- ./deploy/mysql/conf.d:/etc/mysql/conf.d
|
|
- /data/logs/emotion-museum/mysql:/var/log/mysql
|
|
command: --default-authentication-plugin=mysql_native_password
|
|
networks:
|
|
- emotion-network
|
|
|
|
# Redis缓存
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: emotion-redis
|
|
restart: unless-stopped
|
|
ports:
|
|
- "6379:6379"
|
|
volumes:
|
|
- redis_data:/data
|
|
- ./deploy/redis/redis.conf:/usr/local/etc/redis/redis.conf
|
|
- /data/logs/emotion-museum/redis:/var/log/redis
|
|
command: redis-server /usr/local/etc/redis/redis.conf
|
|
networks:
|
|
- emotion-network
|
|
|
|
# Nacos注册中心
|
|
nacos:
|
|
image: nacos/nacos-server:v2.2.0
|
|
container_name: emotion-nacos
|
|
restart: unless-stopped
|
|
environment:
|
|
MODE: standalone
|
|
SPRING_DATASOURCE_PLATFORM: mysql
|
|
MYSQL_SERVICE_HOST: mysql
|
|
MYSQL_SERVICE_DB_NAME: nacos_config
|
|
MYSQL_SERVICE_PORT: 3306
|
|
MYSQL_SERVICE_USER: root
|
|
MYSQL_SERVICE_PASSWORD: 123456
|
|
MYSQL_SERVICE_DB_PARAM: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
|
|
JVM_XMS: 512m
|
|
JVM_XMX: 512m
|
|
JVM_XMN: 256m
|
|
ports:
|
|
- "8848:8848"
|
|
- "9848:9848"
|
|
volumes:
|
|
- nacos_data:/home/nacos/data
|
|
- nacos_logs:/home/nacos/logs
|
|
- /data/logs/emotion-museum/nacos:/home/nacos/logs
|
|
depends_on:
|
|
- mysql
|
|
networks:
|
|
- emotion-network
|
|
|
|
# 网关服务 - 使用宿主机JAR文件
|
|
emotion-gateway:
|
|
image: openjdk:17-jdk-alpine
|
|
container_name: emotion-gateway
|
|
restart: unless-stopped
|
|
working_dir: /app
|
|
command: >
|
|
sh -c "
|
|
apk add --no-cache curl tzdata &&
|
|
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&
|
|
echo 'Asia/Shanghai' > /etc/timezone &&
|
|
java -jar
|
|
-Xms512m -Xmx1024m
|
|
-Djava.security.egd=file:/dev/./urandom
|
|
-Dspring.profiles.active=docker
|
|
-Dlogging.file.path=/app/logs
|
|
/app/emotion-gateway.jar
|
|
"
|
|
ports:
|
|
- "9000:9000"
|
|
environment:
|
|
SPRING_PROFILES_ACTIVE: docker
|
|
NACOS_SERVER_ADDR: nacos:8848
|
|
MYSQL_HOST: mysql
|
|
MYSQL_PORT: 3306
|
|
REDIS_HOST: redis
|
|
REDIS_PORT: 6379
|
|
TZ: Asia/Shanghai
|
|
volumes:
|
|
- /data/builds/emotion-gateway.jar:/app/emotion-gateway.jar:ro
|
|
- /data/logs/emotion-museum/gateway:/app/logs
|
|
depends_on:
|
|
- mysql
|
|
- redis
|
|
- nacos
|
|
networks:
|
|
- emotion-network
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:9000/actuator/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 60s
|
|
|
|
# AI服务 - 使用宿主机JAR文件
|
|
emotion-ai:
|
|
image: openjdk:17-jdk-alpine
|
|
container_name: emotion-ai
|
|
restart: unless-stopped
|
|
working_dir: /app
|
|
command: >
|
|
sh -c "
|
|
apk add --no-cache curl tzdata &&
|
|
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&
|
|
echo 'Asia/Shanghai' > /etc/timezone &&
|
|
java -jar
|
|
-Xms512m -Xmx1024m
|
|
-Djava.security.egd=file:/dev/./urandom
|
|
-Dspring.profiles.active=docker
|
|
-Dlogging.file.path=/app/logs
|
|
/app/emotion-ai.jar
|
|
"
|
|
ports:
|
|
- "9002:9002"
|
|
environment:
|
|
SPRING_PROFILES_ACTIVE: docker
|
|
NACOS_SERVER_ADDR: nacos:8848
|
|
MYSQL_HOST: mysql
|
|
MYSQL_PORT: 3306
|
|
REDIS_HOST: redis
|
|
REDIS_PORT: 6379
|
|
COZE_API_TOKEN: ${COZE_API_TOKEN:-pat_GCR4qKzqpf90wMCvKsldMrB18KG3QsLDci65bZthssKsbLxu8X70BKYumleDcabO}
|
|
TZ: Asia/Shanghai
|
|
volumes:
|
|
- /data/builds/emotion-ai.jar:/app/emotion-ai.jar:ro
|
|
- /data/logs/emotion-museum/ai:/app/logs
|
|
depends_on:
|
|
- mysql
|
|
- redis
|
|
- nacos
|
|
networks:
|
|
- emotion-network
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:9002/actuator/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 60s
|
|
|
|
# 用户服务 - 使用宿主机JAR文件
|
|
emotion-user:
|
|
image: openjdk:17-jdk-alpine
|
|
container_name: emotion-user
|
|
restart: unless-stopped
|
|
working_dir: /app
|
|
command: >
|
|
sh -c "
|
|
apk add --no-cache curl tzdata &&
|
|
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&
|
|
echo 'Asia/Shanghai' > /etc/timezone &&
|
|
java -jar
|
|
-Xms512m -Xmx1024m
|
|
-Djava.security.egd=file:/dev/./urandom
|
|
-Dspring.profiles.active=docker
|
|
-Dlogging.file.path=/app/logs
|
|
/app/emotion-user.jar
|
|
"
|
|
ports:
|
|
- "9001:9001"
|
|
environment:
|
|
SPRING_PROFILES_ACTIVE: docker
|
|
NACOS_SERVER_ADDR: nacos:8848
|
|
MYSQL_HOST: mysql
|
|
MYSQL_PORT: 3306
|
|
REDIS_HOST: redis
|
|
REDIS_PORT: 6379
|
|
TZ: Asia/Shanghai
|
|
volumes:
|
|
- /data/builds/emotion-user.jar:/app/emotion-user.jar:ro
|
|
- /data/logs/emotion-museum/user:/app/logs
|
|
depends_on:
|
|
- mysql
|
|
- redis
|
|
- nacos
|
|
networks:
|
|
- emotion-network
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:9001/actuator/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 60s
|
|
|
|
# Nginx反向代理
|
|
nginx:
|
|
image: nginx:alpine
|
|
container_name: emotion-nginx
|
|
restart: unless-stopped
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- ./deploy/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
- ./deploy/nginx/conf.d:/etc/nginx/conf.d:ro
|
|
- ./deploy/nginx/ssl:/etc/nginx/ssl:ro
|
|
- /data/www/emotion-museum:/data/www/emotion-museum:ro
|
|
- /data/logs/emotion-museum/nginx:/var/log/nginx
|
|
depends_on:
|
|
- emotion-gateway
|
|
- emotion-ai
|
|
- emotion-user
|
|
networks:
|
|
- emotion-network
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost/nginx-health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
volumes:
|
|
mysql_data:
|
|
redis_data:
|
|
nacos_data:
|
|
nacos_logs:
|
|
|
|
networks:
|
|
emotion-network:
|
|
driver: bridge
|