chore(config): Extend production database and Sentinel configuration

This commit is contained in:
2025-04-13 21:56:44 +08:00
parent ede0eee58a
commit 111da1aba6
5 changed files with 263 additions and 0 deletions
+61
View File
@@ -0,0 +1,61 @@
#!/bin/bash
echo "开始构建和部署视频平台项目..."
echo "1. 安装common模块到本地Maven仓库..."
cd video-common
# 使用-Dspring-boot.repackage.skip=true跳过Spring Boot的repackage阶段
mvn clean install -DskipTests -Dspring-boot.repackage.skip=true
cd ..
echo "2. 构建其他模块..."
mvn clean package -DskipTests -pl '!video-common'
echo "3. 构建Sentinel Dashboard镜像..."
# 检查sentinel-dashboard目录是否存在
if [ -d "sentinel-dashboard" ]; then
cd sentinel-dashboard
docker build -t sentinel-dashboard:1.8.6 .
cd ..
else
echo "警告: sentinel-dashboard目录不存在,跳过镜像构建"
# 创建简单的Dockerfile用于构建Sentinel镜像
mkdir -p sentinel-dashboard
cat > sentinel-dashboard/Dockerfile << 'EOF'
FROM eclipse-temurin:8-jre
# 下载 Sentinel 1.8.6 官方 JAR
RUN apt-get update && \
apt-get install -y wget && \
wget -O /sentinel-dashboard.jar \
https://github.com/alibaba/Sentinel/releases/download/1.8.6/sentinel-dashboard-1.8.6.jar && \
apt-get remove -y wget && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# 设置时区
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone
EXPOSE 8080
CMD ["java", "-Dserver.port=8080", "-Dcsp.sentinel.dashboard.server=localhost:8080", "-jar", "/sentinel-dashboard.jar"]
EOF
cd sentinel-dashboard
docker build -t sentinel-dashboard:1.8.6 .
cd ..
fi
echo "4. 启动Docker Compose..."
# 检查docker-compose是否可用
if command -v docker-compose &> /dev/null; then
docker-compose up -d
else
echo "警告: docker-compose命令不可用,尝试使用docker compose命令"
docker compose up -d
fi
echo "部署完成!"
echo "服务访问地址:"
SERVER_IP=$(hostname -I | awk '{print $1}')
echo "- 网关: http://${SERVER_IP}:9000"
echo "- Nacos: http://${SERVER_IP}:8848/nacos"
echo "- Sentinel: http://${SERVER_IP}:8080"
echo "- MinIO: http://${SERVER_IP}:9001"
@@ -0,0 +1,55 @@
server:
port: 9001
spring:
application:
name: video-auth
cloud:
nacos:
discovery:
server-addr: ${NACOS_HOST:nacos}:${NACOS_PORT:8848}
namespace: public
group: DEFAULT_GROUP
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: 8721
eager: true
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/video_auth?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
data:
redis:
host: ${REDIS_HOST:redis}
port: ${REDIS_PORT:6379}
password: redis_EsJ8FX
database: 0
timeout: 10000
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.nuaa.video.auth.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: is_deleted
logic-delete-value: 1
logic-not-delete-value: 0
jwt:
secret: your-secret-key-here-should-be-very-long-and-secure
expiration: 86400000 # 24小时
header: Authorization
tokenPrefix: Bearer
@@ -0,0 +1,49 @@
server:
port: 9005
spring:
application:
name: video-comment
cloud:
nacos:
discovery:
server-addr: ${NACOS_HOST:nacos}:${NACOS_PORT:8848}
namespace: public
group: DEFAULT_GROUP
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: 8725
eager: true
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/video_comment?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
data:
redis:
host: ${REDIS_HOST:redis}
port: ${REDIS_PORT:6379}
password: redis_EsJ8FX
database: 4
timeout: 10000
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.nuaa.video.comment.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: is_deleted
logic-delete-value: 1
logic-not-delete-value: 0
@@ -0,0 +1,49 @@
server:
port: 9006
spring:
application:
name: video-recommend
cloud:
nacos:
discovery:
server-addr: ${NACOS_HOST:nacos}:${NACOS_PORT:8848}
namespace: public
group: DEFAULT_GROUP
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: 8726
eager: true
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/video_recommend?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
data:
redis:
host: ${REDIS_HOST:redis}
port: ${REDIS_PORT:6379}
password: redis_EsJ8FX
database: 5
timeout: 10000
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.nuaa.video.recommend.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: is_deleted
logic-delete-value: 1
logic-not-delete-value: 0
@@ -0,0 +1,49 @@
server:
port: 9002
spring:
application:
name: video-user
cloud:
nacos:
discovery:
server-addr: ${NACOS_HOST:nacos}:${NACOS_PORT:8848}
namespace: public
group: DEFAULT_GROUP
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: 8722
eager: true
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/video_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
data:
redis:
host: ${REDIS_HOST:redis}
port: ${REDIS_PORT:6379}
password: redis_EsJ8FX
database: 1
timeout: 10000
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.nuaa.video.user.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: is_deleted
logic-delete-value: 1
logic-not-delete-value: 0