配置优化:添加Actuator健康检查依赖并优化Docker部署配置

This commit is contained in:
2025-10-14 20:32:28 +08:00
parent cfd1f7a492
commit 388199279a
3 changed files with 23 additions and 14 deletions

View File

@@ -7,7 +7,7 @@ services:
container_name: light-delivery-container
ports:
- "8080:8080"
- "8443:8443"
- "8443:443" # 修改这行将宿主机8443端口映射到容器443端口
environment:
- SPRING_DATASOURCE_PASSWORD=Hu@ng1998!
- KEY_STORE_PASSWORD=k7cP6QLgJDkX
@@ -23,11 +23,11 @@ services:
networks:
- light-network
healthcheck:
test: ["CMD", "curl", "-f", "https://localhost:8443/actuator/health", "--insecure"]
test: ["CMD", "wget", "--no-check-certificate", "-qO-", "https://localhost:443/actuator/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
start_period: 40s
networks:
light-network:

16
pom.xml
View File

@@ -119,6 +119,12 @@
<optional>true</optional>
</dependency>
<!-- ========== Actuator for Health Check ========== -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- ========== Test Dependencies ========== -->
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -163,6 +169,16 @@
</configuration>
</plugin>
<!-- 添加资源插件以确保正确处理UTF-8编码 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- Jib Docker Plugin -->
<plugin>
<groupId>com.google.cloud.tools</groupId>

View File

@@ -1,45 +1,38 @@
spring.application.name=Light
# 服务器端口配置
server.port=443
# SSL配置
server.ssl.key-store-type=JKS
server.ssl.key-store=/etc/ssl/certs/www.doubleyin.cn.jks
server.ssl.key-store-password=${KEY_STORE_PASSWORD}
# --- MySQL Database Configuration (Remote Server) ---
spring.datasource.url=jdbc:mysql://115.190.121.151:3306/light_delivery?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.datasource.username=double
spring.datasource.password=Hu@ng1998!
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# JPA / Hibernate Settings
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
# For MySQL
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
# HikariCP Connection Pool Settings
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.minimum-idle=2
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.idle-timeout=600000
spring.datasource.hikari.max-lifetime=1800000
# ------ WeChat Configuration ------
wx.appId=wx1b790fd953ac27bf
wx.secret=b38c40c89cc4954472fb45d1e7cc27a4
wx.token=huang1998
wx.aesKey=lwararkj1BgurX8Qown6yjGNsqd8dEIEddDnYN3iLgc
# WeChat API URLs
wx.api.access-token-url=https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential
wx.api.code2session-url=https://api.weixin.qq.com/sns/jscode2session
# Logging Configuration
logging.level.com.light.delivery=INFO
# JWT Configuration
jwt.secret=lightDeliveryProdSecretKey
jwt.expiration=86400
jwt.expiration=86400
management.endpoints.web.exposure.include=health,info
management.endpoint.health.show-details=always