## Docker 容器化部署 ### 新增文件 - Dockerfile: 多阶段构建镜像,支持 Java 21 - docker-compose.yml: 完整服务编排配置 - 基础设施: MySQL 8.0, Redis 7, Nacos 3.0 - 监控: Prometheus, Grafana - 业务服务: Gateway + 9个微服务 - docker/.env: 环境变量配置 - docker/mysql/init/01-init.sql: 数据库初始化脚本 ### Docker 特性 - 多阶段构建优化镜像大小 - 非 root 用户运行服务 - 健康检查配置 - 统一时区设置 (Asia/Shanghai) ## Prometheus + Grafana 监控 ### Prometheus 配置 - docker/prometheus/prometheus.yml: 服务发现配置 - docker/prometheus/rules/alerts.yml: 告警规则 - 服务可用性告警 - JVM 内存告警 - HTTP 请求告警 - 数据库连接池告警 - 系统资源告警 ### Grafana 配置 - docker/grafana/provisioning/: 数据源和Dashboard自动导入 - docker/grafana/dashboards/fund-platform-dashboard.json - 服务概览面板 - JVM 内存监控 - 数据库连接池监控 ### Spring Boot Actuator 集成 - pom.xml: 添加 spring-boot-starter-actuator 和 micrometer-registry-prometheus - application-docker.yml: Prometheus 端点配置 ## 服务端口规划 - Gateway: 8000 - fund-sys: 8100 - fund-cust: 8200 - fund-proj: 8300 - fund-req: 8400 - fund-exp: 8500 - fund-receipt: 8600 - fund-report: 8700 - fund-file: 8800 - Prometheus: 9090 - Grafana: 3000 - Nacos: 8848
114 lines
2.6 KiB
YAML
114 lines
2.6 KiB
YAML
# Docker 环境配置 - Gateway
|
|
server:
|
|
port: ${SERVER_PORT:8000}
|
|
|
|
spring:
|
|
application:
|
|
name: fund-gateway
|
|
profiles:
|
|
active: ${SPRING_PROFILES_ACTIVE:docker}
|
|
|
|
cloud:
|
|
nacos:
|
|
server-addr: ${NACOS_SERVER_ADDR:nacos:8848}
|
|
username: ${NACOS_USERNAME:nacos}
|
|
password: ${NACOS_PASSWORD:nacos}
|
|
discovery:
|
|
namespace: ${NACOS_NAMESPACE:}
|
|
group: DEFAULT_GROUP
|
|
enabled: true
|
|
|
|
gateway:
|
|
discovery:
|
|
locator:
|
|
enabled: true
|
|
lower-case-service-id: true
|
|
routes:
|
|
- id: fund-sys
|
|
uri: lb://fund-sys
|
|
predicates:
|
|
- Path=/api/sys/**
|
|
filters:
|
|
- StripPrefix=1
|
|
- id: fund-cust
|
|
uri: lb://fund-cust
|
|
predicates:
|
|
- Path=/api/cust/**
|
|
filters:
|
|
- StripPrefix=1
|
|
- id: fund-proj
|
|
uri: lb://fund-proj
|
|
predicates:
|
|
- Path=/api/proj/**
|
|
filters:
|
|
- StripPrefix=1
|
|
- id: fund-req
|
|
uri: lb://fund-req
|
|
predicates:
|
|
- Path=/api/req/**
|
|
filters:
|
|
- StripPrefix=1
|
|
- id: fund-exp
|
|
uri: lb://fund-exp
|
|
predicates:
|
|
- Path=/api/exp/**
|
|
filters:
|
|
- StripPrefix=1
|
|
- id: fund-receipt
|
|
uri: lb://fund-receipt
|
|
predicates:
|
|
- Path=/api/receipt/**
|
|
filters:
|
|
- StripPrefix=1
|
|
- id: fund-report
|
|
uri: lb://fund-report
|
|
predicates:
|
|
- Path=/api/report/**
|
|
filters:
|
|
- StripPrefix=1
|
|
- id: fund-file
|
|
uri: lb://fund-file
|
|
predicates:
|
|
- Path=/api/file/**
|
|
filters:
|
|
- StripPrefix=1
|
|
|
|
# JWT 配置
|
|
jwt:
|
|
secret: YourSecretKeyForJWTTokenGenerationMustBeAtLeast256BitsLong
|
|
expiration: 86400000
|
|
|
|
# Actuator 监控端点配置
|
|
management:
|
|
endpoints:
|
|
web:
|
|
exposure:
|
|
include: health,info,metrics,prometheus
|
|
base-path: /actuator
|
|
endpoint:
|
|
health:
|
|
show-details: always
|
|
probes:
|
|
enabled: true
|
|
health:
|
|
livenessstate:
|
|
enabled: true
|
|
readinessstate:
|
|
enabled: true
|
|
metrics:
|
|
tags:
|
|
application: ${spring.application.name}
|
|
distribution:
|
|
percentiles-histogram:
|
|
http.server.requests: true
|
|
percentiles:
|
|
http.server.requests: 0.5,0.95,0.99
|
|
|
|
# 日志配置
|
|
logging:
|
|
level:
|
|
root: INFO
|
|
com.fundplatform: DEBUG
|
|
pattern:
|
|
console: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%X{traceId}] %-5level %logger{36} - %msg%n"
|