From 480c052ff1944b45ddc40e7294061ecf3f6a6eb8 Mon Sep 17 00:00:00 2001 From: zhangjf Date: Fri, 20 Feb 2026 10:13:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Docker=E5=AE=B9=E5=99=A8=E5=8C=96?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加所有后端服务的application-docker.yml配置文件 - 添加前端fund-admin和fund-mobile的Dockerfile和nginx配置 - 更新docker-compose.yml添加前端服务 - 添加.dockerignore优化构建 - 添加deploy.sh一键部署脚本 --- .dockerignore | 50 ++++ deploy.sh | 266 ++++++++++++++++++ docker-compose.yml | 48 ++++ fund-admin/.dockerignore | 31 ++ fund-admin/Dockerfile | 61 ++++ fund-admin/nginx.conf | 54 ++++ .../src/main/resources/application-docker.yml | 51 ++++ .../src/main/resources/application-docker.yml | 51 ++++ .../src/main/resources/application-docker.yml | 63 +++++ .../src/main/resources/application-docker.yml | 114 ++++++++ fund-mobile/.dockerignore | 31 ++ fund-mobile/Dockerfile | 61 ++++ fund-mobile/nginx.conf | 54 ++++ .../src/main/resources/application-docker.yml | 51 ++++ .../src/main/resources/application-docker.yml | 56 ++++ .../src/main/resources/application-docker.yml | 51 ++++ .../src/main/resources/application-docker.yml | 51 ++++ .../src/main/resources/application-docker.yml | 82 ++++++ 18 files changed, 1226 insertions(+) create mode 100644 .dockerignore create mode 100755 deploy.sh create mode 100644 fund-admin/.dockerignore create mode 100644 fund-admin/Dockerfile create mode 100644 fund-admin/nginx.conf create mode 100644 fund-cust/src/main/resources/application-docker.yml create mode 100644 fund-exp/src/main/resources/application-docker.yml create mode 100644 fund-file/src/main/resources/application-docker.yml create mode 100644 fund-gateway/src/main/resources/application-docker.yml create mode 100644 fund-mobile/.dockerignore create mode 100644 fund-mobile/Dockerfile create mode 100644 fund-mobile/nginx.conf create mode 100644 fund-proj/src/main/resources/application-docker.yml create mode 100644 fund-receipt/src/main/resources/application-docker.yml create mode 100644 fund-report/src/main/resources/application-docker.yml create mode 100644 fund-req/src/main/resources/application-docker.yml create mode 100644 fund-sys/src/main/resources/application-docker.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c0f2289 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,50 @@ +# Git +.git +.gitignore + +# IDE +.idea +.vscode +*.iml +*.ipr +*.iws + +# Node modules +**/node_modules + +# Build output +**/dist +**/target + +# Logs +**/logs +*.log + +# Documentation +*.md +doc/ + +# Docker +docker/ +Dockerfile +docker-compose*.yml + +# Test files +**/test +**/__tests__ +**/*.test.ts +**/*.test.js +**/*.spec.ts +**/*.spec.js + +# Environment files +.env +.env.* +!.env.example + +# OS files +.DS_Store +Thumbs.db + +# Qoder +.qoder/ diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..7e8f339 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,266 @@ +#!/bin/bash +# 资金服务平台 - Docker 部署脚本 + +set -e + +# 颜色定义 +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# 打印带颜色的消息 +log_info() { + echo -e "${GREEN}[INFO]${NC} $1" +} + +log_warn() { + echo -e "${YELLOW}[WARN]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +# 显示帮助 +show_help() { + echo "资金服务平台 Docker 部署脚本" + echo "" + echo "用法: $0 <命令> [选项]" + echo "" + echo "命令:" + echo " start 启动所有服务" + echo " stop 停止所有服务" + echo " restart 重启所有服务" + echo " build 构建所有镜像" + echo " rebuild 重新构建所有镜像(不使用缓存)" + echo " logs 查看服务日志" + echo " status 查看服务状态" + echo " clean 清理未使用的镜像和容器" + echo " init 初始化环境(首次部署)" + echo "" + echo "选项:" + echo " --service 指定服务名称" + echo " --no-cache 构建时不使用缓存" + echo "" + echo "示例:" + echo " $0 start # 启动所有服务" + echo " $0 build --no-cache # 重新构建所有镜像" + echo " $0 logs --service fund-sys # 查看系统服务日志" +} + +# 检查 Docker 环境 +check_docker() { + if ! command -v docker &> /dev/null; then + log_error "Docker 未安装,请先安装 Docker" + exit 1 + fi + + if ! docker info &> /dev/null; then + log_error "Docker 未运行,请先启动 Docker" + exit 1 + fi + + if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then + log_error "Docker Compose 未安装" + exit 1 + fi + + log_info "Docker 环境检查通过" +} + +# 使用 docker-compose 命令(兼容 v1 和 v2) +compose_cmd() { + if docker compose version &> /dev/null; then + docker compose "$@" + else + docker-compose "$@" + fi +} + +# 初始化环境 +init_env() { + log_info "初始化部署环境..." + + # 复制环境配置 + if [ ! -f .env ]; then + cp docker/.env .env + log_info "已创建 .env 文件" + else + log_warn ".env 文件已存在,跳过" + fi + + # 创建必要的目录 + mkdir -p docker/grafana/dashboards + mkdir -p docker/grafana/provisioning/datasources + mkdir -p docker/grafana/provisioning/dashboards + mkdir -p docker/prometheus/rules + + # 设置权限 + chmod +x deploy.sh 2>/dev/null || true + + log_info "环境初始化完成" +} + +# 构建镜像 +build_images() { + local no_cache="" + local service="" + + while [[ $# -gt 0 ]]; do + case $1 in + --no-cache) + no_cache="--no-cache" + shift + ;; + --service) + service="$2" + shift 2 + ;; + *) + shift + ;; + esac + done + + log_info "开始构建 Docker 镜像..." + + if [ -n "$service" ]; then + compose_cmd build $no_cache "$service" + else + compose_cmd build $no_cache + fi + + log_info "镜像构建完成" +} + +# 启动服务 +start_services() { + log_info "启动服务..." + compose_cmd up -d + + log_info "等待服务启动..." + sleep 10 + + log_info "服务状态:" + compose_cmd ps +} + +# 停止服务 +stop_services() { + log_info "停止服务..." + compose_cmd down + log_info "服务已停止" +} + +# 重启服务 +restart_services() { + stop_services + sleep 3 + start_services +} + +# 查看日志 +view_logs() { + local service="" + + while [[ $# -gt 0 ]]; do + case $1 in + --service) + service="$2" + shift 2 + ;; + *) + shift + ;; + esac + done + + if [ -n "$service" ]; then + compose_cmd logs -f "$service" + else + compose_cmd logs -f + fi +} + +# 查看状态 +view_status() { + log_info "服务状态:" + compose_cmd ps + + echo "" + log_info "健康检查:" + compose_cmd ps --format "table {{.Name}}\t{{.Status}}" +} + +# 清理 +clean_up() { + log_info "清理未使用的资源..." + + # 停止并删除所有容器 + compose_cmd down -v --remove-orphans + + # 删除悬空镜像 + docker image prune -f + + # 删除未使用的网络 + docker network prune -f + + log_info "清理完成" +} + +# 主函数 +main() { + if [ $# -eq 0 ]; then + show_help + exit 0 + fi + + check_docker + + case $1 in + start) + shift + start_services "$@" + ;; + stop) + shift + stop_services "$@" + ;; + restart) + shift + restart_services "$@" + ;; + build) + shift + build_images "$@" + ;; + rebuild) + shift + build_images --no-cache "$@" + ;; + logs) + shift + view_logs "$@" + ;; + status) + view_status + ;; + clean) + clean_up + ;; + init) + init_env + ;; + -h|--help) + show_help + ;; + *) + log_error "未知命令: $1" + show_help + exit 1 + ;; + esac +} + +main "$@" diff --git a/docker-compose.yml b/docker-compose.yml index 3880a0b..ddd798a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -510,6 +510,54 @@ services: networks: - fund-network + # ==================== 前端服务 ==================== + + # 管理后台前端 + fund-admin: + build: + context: ./fund-admin + dockerfile: Dockerfile + args: + VITE_API_BASE_URL: http://localhost:8000 + container_name: fund-admin + restart: unless-stopped + ports: + - "80:80" + depends_on: + gateway: + condition: service_healthy + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost/"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 10s + networks: + - fund-network + + # 移动端H5 + fund-mobile: + build: + context: ./fund-mobile + dockerfile: Dockerfile + args: + VITE_API_BASE_URL: http://localhost:8000 + container_name: fund-mobile + restart: unless-stopped + ports: + - "81:80" + depends_on: + gateway: + condition: service_healthy + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost/"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 10s + networks: + - fund-network + # ==================== 网络配置 ==================== networks: fund-network: diff --git a/fund-admin/.dockerignore b/fund-admin/.dockerignore new file mode 100644 index 0000000..8e1fe51 --- /dev/null +++ b/fund-admin/.dockerignore @@ -0,0 +1,31 @@ +# Dependencies +node_modules + +# Build output +dist + +# IDE +.idea +.vscode +*.iml + +# Git +.git +.gitignore + +# Logs +*.log +npm-debug.log* + +# Environment +.env +.env.* +!.env.example + +# OS +.DS_Store +Thumbs.db + +# Test +**/*.test.ts +**/*.spec.ts diff --git a/fund-admin/Dockerfile b/fund-admin/Dockerfile new file mode 100644 index 0000000..d1b82a4 --- /dev/null +++ b/fund-admin/Dockerfile @@ -0,0 +1,61 @@ +# 资金服务平台管理后台 - Dockerfile +# 多阶段构建:Node构建 + Nginx运行 + +# ==================== 构建阶段 ==================== +FROM node:20-alpine AS builder + +WORKDIR /app + +# 设置npm镜像(加速下载) +RUN npm config set registry https://registry.npmmirror.com + +# 复制package文件(利用缓存) +COPY package*.json ./ + +# 安装依赖 +RUN npm ci --legacy-peer-deps + +# 复制源代码 +COPY . . + +# 构建参数:API网关地址 +ARG VITE_API_BASE_URL=http://localhost:8000 +ENV VITE_API_BASE_URL=${VITE_API_BASE_URL} + +# 构建生产版本 +RUN npm run build + +# ==================== 运行阶段 ==================== +FROM nginx:alpine + +# 安装必要工具 +RUN apk add --no-cache curl tzdata && \ + cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ + echo "Asia/Shanghai" > /etc/timezone && \ + apk del tzdata + +# 删除默认配置 +RUN rm -rf /etc/nginx/conf.d/default.conf + +# 复制nginx配置 +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# 复制构建产物 +COPY --from=builder /app/dist /usr/share/nginx/html + +# 创建非root用户 +RUN chown -R nginx:nginx /usr/share/nginx/html && \ + chown -R nginx:nginx /var/cache/nginx && \ + chown -R nginx:nginx /var/log/nginx && \ + touch /var/run/nginx.pid && \ + chown -R nginx:nginx /var/run/nginx.pid + +# 暴露端口 +EXPOSE 80 + +# 健康检查 +HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \ + CMD curl -f http://localhost/ || exit 1 + +# 启动nginx +CMD ["nginx", "-g", "daemon off;"] diff --git a/fund-admin/nginx.conf b/fund-admin/nginx.conf new file mode 100644 index 0000000..b079212 --- /dev/null +++ b/fund-admin/nginx.conf @@ -0,0 +1,54 @@ +# 资金服务平台管理后台 Nginx 配置 +server { + listen 80; + server_name localhost; + root /usr/share/nginx/html; + index index.html; + + # Gzip压缩 + gzip on; + gzip_min_length 1k; + gzip_comp_level 6; + gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml; + gzip_vary on; + gzip_disable "MSIE [1-6]\."; + + # 静态资源缓存 + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # API代理到网关 + location /api/ { + proxy_pass http://fund-gateway:8000/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + # 超时配置 + proxy_connect_timeout 60s; + proxy_send_timeout 60s; + proxy_read_timeout 60s; + + # 文件上传大小限制 + client_max_body_size 100m; + } + + # Vue Router History模式支持 + location / { + try_files $uri $uri/ /index.html; + } + + # 安全头 + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-XSS-Protection "1; mode=block" always; + + # 错误页面 + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} diff --git a/fund-cust/src/main/resources/application-docker.yml b/fund-cust/src/main/resources/application-docker.yml new file mode 100644 index 0000000..920e00e --- /dev/null +++ b/fund-cust/src/main/resources/application-docker.yml @@ -0,0 +1,51 @@ +# Docker 环境配置 +server: + port: ${SERVER_PORT:8200} + +spring: + cloud: + nacos: + discovery: + server-addr: ${NACOS_SERVER_ADDR:nacos:8848} + namespace: fund-platform + group: DEFAULT_GROUP + username: ${NACOS_USERNAME:nacos} + password: ${NACOS_PASSWORD:nacos} + metadata: + tenant-id: ${TENANT_ID:} + + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:fund_platform}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai + username: ${MYSQL_USER:root} + password: ${MYSQL_PASSWORD:root123} + hikari: + maximum-pool-size: 20 + minimum-idle: 5 + connection-timeout: 30000 + idle-timeout: 600000 + max-lifetime: 1800000 + validation-timeout: 5000 + leak-detection-threshold: 60000 + pool-name: FundCustHikariPool + connection-init-sql: SELECT 1 + +logging: + level: + com.fundplatform.cust: INFO + +management: + endpoints: + web: + exposure: + include: health,info,metrics,prometheus + endpoint: + health: + show-details: when_authorized + +tenant: + routing: + enabled: true + tenant-header: X-Tenant-Id + default-tenant-id: "1" + fallback-to-shared: true diff --git a/fund-exp/src/main/resources/application-docker.yml b/fund-exp/src/main/resources/application-docker.yml new file mode 100644 index 0000000..7635b36 --- /dev/null +++ b/fund-exp/src/main/resources/application-docker.yml @@ -0,0 +1,51 @@ +# Docker 环境配置 +server: + port: ${SERVER_PORT:8500} + +spring: + cloud: + nacos: + discovery: + server-addr: ${NACOS_SERVER_ADDR:nacos:8848} + namespace: fund-platform + group: DEFAULT_GROUP + username: ${NACOS_USERNAME:nacos} + password: ${NACOS_PASSWORD:nacos} + metadata: + tenant-id: ${TENANT_ID:} + + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:fund_platform}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai + username: ${MYSQL_USER:root} + password: ${MYSQL_PASSWORD:root123} + hikari: + maximum-pool-size: 20 + minimum-idle: 5 + connection-timeout: 30000 + idle-timeout: 600000 + max-lifetime: 1800000 + validation-timeout: 5000 + leak-detection-threshold: 60000 + pool-name: FundExpHikariPool + connection-init-sql: SELECT 1 + +logging: + level: + com.fundplatform.exp: INFO + +management: + endpoints: + web: + exposure: + include: health,info,metrics,prometheus + endpoint: + health: + show-details: when_authorized + +tenant: + routing: + enabled: true + tenant-header: X-Tenant-Id + default-tenant-id: "1" + fallback-to-shared: true diff --git a/fund-file/src/main/resources/application-docker.yml b/fund-file/src/main/resources/application-docker.yml new file mode 100644 index 0000000..c0ff01d --- /dev/null +++ b/fund-file/src/main/resources/application-docker.yml @@ -0,0 +1,63 @@ +# Docker 环境配置 +server: + port: ${SERVER_PORT:8800} + +spring: + cloud: + nacos: + discovery: + server-addr: ${NACOS_SERVER_ADDR:nacos:8848} + namespace: fund-platform + group: DEFAULT_GROUP + username: ${NACOS_USERNAME:nacos} + password: ${NACOS_PASSWORD:nacos} + metadata: + tenant-id: ${TENANT_ID:} + + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:fund_platform}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai + username: ${MYSQL_USER:root} + password: ${MYSQL_PASSWORD:root123} + hikari: + maximum-pool-size: 20 + minimum-idle: 5 + connection-timeout: 30000 + idle-timeout: 600000 + max-lifetime: 1800000 + validation-timeout: 5000 + leak-detection-threshold: 60000 + pool-name: FundFileHikariPool + connection-init-sql: SELECT 1 + +# 文件存储配置 +file: + storage: + type: ${FILE_STORAGE_TYPE:local} + local: + path: ${FILE_STORAGE_PATH:/data/files} + minio: + endpoint: ${MINIO_ENDPOINT:http://minio:9000} + access-key: ${MINIO_ACCESS_KEY:minioadmin} + secret-key: ${MINIO_SECRET_KEY:minioadmin} + bucket: ${MINIO_BUCKET:fund-files} + +logging: + level: + com.fundplatform.file: INFO + +management: + endpoints: + web: + exposure: + include: health,info,metrics,prometheus + endpoint: + health: + show-details: when_authorized + +tenant: + routing: + enabled: true + tenant-header: X-Tenant-Id + default-tenant-id: "1" + fallback-to-shared: true diff --git a/fund-gateway/src/main/resources/application-docker.yml b/fund-gateway/src/main/resources/application-docker.yml new file mode 100644 index 0000000..0bb867a --- /dev/null +++ b/fund-gateway/src/main/resources/application-docker.yml @@ -0,0 +1,114 @@ +# Docker 环境配置 +server: + port: ${SERVER_PORT:8000} + +spring: + cloud: + nacos: + discovery: + server-addr: ${NACOS_SERVER_ADDR:nacos:8848} + namespace: fund-platform + group: DEFAULT_GROUP + username: ${NACOS_USERNAME:nacos} + password: ${NACOS_PASSWORD:nacos} + + sentinel: + transport: + dashboard: ${SENTINEL_DASHBOARD:}:8080 + port: 8719 + eager: true + + gateway: + default-filters: + - name: RequestRateLimiter + args: + redis-rate-limiter.replenishRate: 100 + redis-rate-limiter.burstCapacity: 200 + key-resolver: "#{@ipKeyResolver}" + + globalcors: + cors-configurations: + '[/**]': + allowedOriginPatterns: "*" + allowedMethods: "*" + allowedHeaders: "*" + allowCredentials: true + maxAge: 3600 + + routes: + - id: fund-sys + uri: lb://fund-sys + predicates: + - Path=/sys/** + filters: + - StripPrefix=1 + + - id: fund-cust + uri: lb://fund-cust + predicates: + - Path=/cust/** + filters: + - StripPrefix=1 + + - id: fund-proj + uri: lb://fund-proj + predicates: + - Path=/proj/** + filters: + - StripPrefix=1 + + - id: fund-req + uri: lb://fund-req + predicates: + - Path=/req/** + filters: + - StripPrefix=1 + + - id: fund-exp + uri: lb://fund-exp + predicates: + - Path=/exp/** + filters: + - StripPrefix=1 + + - id: fund-receipt + uri: lb://fund-receipt + predicates: + - Path=/receipt/** + filters: + - StripPrefix=1 + + - id: fund-report + uri: lb://fund-report + predicates: + - Path=/report/** + filters: + - StripPrefix=1 + + - id: fund-file + uri: lb://fund-file + predicates: + - Path=/file/** + filters: + - StripPrefix=1 + + data: + redis: + host: ${REDIS_HOST:redis} + port: ${REDIS_PORT:6379} + password: ${REDIS_PASSWORD:} + database: 1 + +logging: + level: + org.springframework.cloud.gateway: INFO + com.fundplatform.common: INFO + +management: + endpoints: + web: + exposure: + include: health,info,metrics,prometheus + endpoint: + health: + show-details: when_authorized diff --git a/fund-mobile/.dockerignore b/fund-mobile/.dockerignore new file mode 100644 index 0000000..8e1fe51 --- /dev/null +++ b/fund-mobile/.dockerignore @@ -0,0 +1,31 @@ +# Dependencies +node_modules + +# Build output +dist + +# IDE +.idea +.vscode +*.iml + +# Git +.git +.gitignore + +# Logs +*.log +npm-debug.log* + +# Environment +.env +.env.* +!.env.example + +# OS +.DS_Store +Thumbs.db + +# Test +**/*.test.ts +**/*.spec.ts diff --git a/fund-mobile/Dockerfile b/fund-mobile/Dockerfile new file mode 100644 index 0000000..7cdb451 --- /dev/null +++ b/fund-mobile/Dockerfile @@ -0,0 +1,61 @@ +# 资金服务平台移动端 - Dockerfile +# 多阶段构建:Node构建 + Nginx运行 + +# ==================== 构建阶段 ==================== +FROM node:20-alpine AS builder + +WORKDIR /app + +# 设置npm镜像(加速下载) +RUN npm config set registry https://registry.npmmirror.com + +# 复制package文件(利用缓存) +COPY package*.json ./ + +# 安装依赖 +RUN npm ci --legacy-peer-deps + +# 复制源代码 +COPY . . + +# 构建参数:API网关地址 +ARG VITE_API_BASE_URL=http://localhost:8000 +ENV VITE_API_BASE_URL=${VITE_API_BASE_URL} + +# 构建生产版本 +RUN npm run build + +# ==================== 运行阶段 ==================== +FROM nginx:alpine + +# 安装必要工具 +RUN apk add --no-cache curl tzdata && \ + cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ + echo "Asia/Shanghai" > /etc/timezone && \ + apk del tzdata + +# 删除默认配置 +RUN rm -rf /etc/nginx/conf.d/default.conf + +# 复制nginx配置 +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# 复制构建产物 +COPY --from=builder /app/dist /usr/share/nginx/html + +# 创建非root用户 +RUN chown -R nginx:nginx /usr/share/nginx/html && \ + chown -R nginx:nginx /var/cache/nginx && \ + chown -R nginx:nginx /var/log/nginx && \ + touch /var/run/nginx.pid && \ + chown -R nginx:nginx /var/run/nginx.pid + +# 暴露端口 +EXPOSE 80 + +# 健康检查 +HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \ + CMD curl -f http://localhost/ || exit 1 + +# 启动nginx +CMD ["nginx", "-g", "daemon off;"] diff --git a/fund-mobile/nginx.conf b/fund-mobile/nginx.conf new file mode 100644 index 0000000..593b565 --- /dev/null +++ b/fund-mobile/nginx.conf @@ -0,0 +1,54 @@ +# 资金服务平台移动端 Nginx 配置 +server { + listen 80; + server_name localhost; + root /usr/share/nginx/html; + index index.html; + + # Gzip压缩 + gzip on; + gzip_min_length 1k; + gzip_comp_level 6; + gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml; + gzip_vary on; + gzip_disable "MSIE [1-6]\."; + + # 静态资源缓存 + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # API代理到网关 + location /api/ { + proxy_pass http://fund-gateway:8000/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + # 超时配置 + proxy_connect_timeout 60s; + proxy_send_timeout 60s; + proxy_read_timeout 60s; + + # 文件上传大小限制 + client_max_body_size 100m; + } + + # Vue Router History模式支持 + location / { + try_files $uri $uri/ /index.html; + } + + # 安全头 + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-XSS-Protection "1; mode=block" always; + + # 错误页面 + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} diff --git a/fund-proj/src/main/resources/application-docker.yml b/fund-proj/src/main/resources/application-docker.yml new file mode 100644 index 0000000..fe6e569 --- /dev/null +++ b/fund-proj/src/main/resources/application-docker.yml @@ -0,0 +1,51 @@ +# Docker 环境配置 +server: + port: ${SERVER_PORT:8300} + +spring: + cloud: + nacos: + discovery: + server-addr: ${NACOS_SERVER_ADDR:nacos:8848} + namespace: fund-platform + group: DEFAULT_GROUP + username: ${NACOS_USERNAME:nacos} + password: ${NACOS_PASSWORD:nacos} + metadata: + tenant-id: ${TENANT_ID:} + + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:fund_platform}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai + username: ${MYSQL_USER:root} + password: ${MYSQL_PASSWORD:root123} + hikari: + maximum-pool-size: 20 + minimum-idle: 5 + connection-timeout: 30000 + idle-timeout: 600000 + max-lifetime: 1800000 + validation-timeout: 5000 + leak-detection-threshold: 60000 + pool-name: FundProjHikariPool + connection-init-sql: SELECT 1 + +logging: + level: + com.fundplatform.proj: INFO + +management: + endpoints: + web: + exposure: + include: health,info,metrics,prometheus + endpoint: + health: + show-details: when_authorized + +tenant: + routing: + enabled: true + tenant-header: X-Tenant-Id + default-tenant-id: "1" + fallback-to-shared: true diff --git a/fund-receipt/src/main/resources/application-docker.yml b/fund-receipt/src/main/resources/application-docker.yml new file mode 100644 index 0000000..a3749a2 --- /dev/null +++ b/fund-receipt/src/main/resources/application-docker.yml @@ -0,0 +1,56 @@ +# Docker 环境配置 +server: + port: ${SERVER_PORT:8600} + +spring: + cloud: + nacos: + discovery: + server-addr: ${NACOS_SERVER_ADDR:nacos:8848} + namespace: fund-platform + group: DEFAULT_GROUP + username: ${NACOS_USERNAME:nacos} + password: ${NACOS_PASSWORD:nacos} + metadata: + tenant-id: ${TENANT_ID:} + + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:fund_platform}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai + username: ${MYSQL_USER:root} + password: ${MYSQL_PASSWORD:root123} + hikari: + maximum-pool-size: 20 + minimum-idle: 5 + connection-timeout: 30000 + idle-timeout: 600000 + max-lifetime: 1800000 + validation-timeout: 5000 + leak-detection-threshold: 60000 + pool-name: FundReceiptHikariPool + connection-init-sql: SELECT 1 + +logging: + level: + com.fundplatform.receipt: INFO + +management: + endpoints: + web: + exposure: + include: health,info,metrics,prometheus + endpoint: + health: + show-details: when_authorized + +tenant: + routing: + enabled: true + tenant-header: X-Tenant-Id + default-tenant-id: "1" + fallback-to-shared: true + +# 定时任务配置 +fund: + schedule: + enabled: ${SCHEDULE_ENABLED:true} diff --git a/fund-report/src/main/resources/application-docker.yml b/fund-report/src/main/resources/application-docker.yml new file mode 100644 index 0000000..dd8a4fd --- /dev/null +++ b/fund-report/src/main/resources/application-docker.yml @@ -0,0 +1,51 @@ +# Docker 环境配置 +server: + port: ${SERVER_PORT:8700} + +spring: + cloud: + nacos: + discovery: + server-addr: ${NACOS_SERVER_ADDR:nacos:8848} + namespace: fund-platform + group: DEFAULT_GROUP + username: ${NACOS_USERNAME:nacos} + password: ${NACOS_PASSWORD:nacos} + metadata: + tenant-id: ${TENANT_ID:} + + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:fund_platform}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai + username: ${MYSQL_USER:root} + password: ${MYSQL_PASSWORD:root123} + hikari: + maximum-pool-size: 20 + minimum-idle: 5 + connection-timeout: 30000 + idle-timeout: 600000 + max-lifetime: 1800000 + validation-timeout: 5000 + leak-detection-threshold: 60000 + pool-name: FundReportHikariPool + connection-init-sql: SELECT 1 + +logging: + level: + com.fundplatform.report: INFO + +management: + endpoints: + web: + exposure: + include: health,info,metrics,prometheus + endpoint: + health: + show-details: when_authorized + +tenant: + routing: + enabled: true + tenant-header: X-Tenant-Id + default-tenant-id: "1" + fallback-to-shared: true diff --git a/fund-req/src/main/resources/application-docker.yml b/fund-req/src/main/resources/application-docker.yml new file mode 100644 index 0000000..5fe49e8 --- /dev/null +++ b/fund-req/src/main/resources/application-docker.yml @@ -0,0 +1,51 @@ +# Docker 环境配置 +server: + port: ${SERVER_PORT:8400} + +spring: + cloud: + nacos: + discovery: + server-addr: ${NACOS_SERVER_ADDR:nacos:8848} + namespace: fund-platform + group: DEFAULT_GROUP + username: ${NACOS_USERNAME:nacos} + password: ${NACOS_PASSWORD:nacos} + metadata: + tenant-id: ${TENANT_ID:} + + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:fund_platform}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai + username: ${MYSQL_USER:root} + password: ${MYSQL_PASSWORD:root123} + hikari: + maximum-pool-size: 20 + minimum-idle: 5 + connection-timeout: 30000 + idle-timeout: 600000 + max-lifetime: 1800000 + validation-timeout: 5000 + leak-detection-threshold: 60000 + pool-name: FundReqHikariPool + connection-init-sql: SELECT 1 + +logging: + level: + com.fundplatform.req: INFO + +management: + endpoints: + web: + exposure: + include: health,info,metrics,prometheus + endpoint: + health: + show-details: when_authorized + +tenant: + routing: + enabled: true + tenant-header: X-Tenant-Id + default-tenant-id: "1" + fallback-to-shared: true diff --git a/fund-sys/src/main/resources/application-docker.yml b/fund-sys/src/main/resources/application-docker.yml new file mode 100644 index 0000000..ae882ae --- /dev/null +++ b/fund-sys/src/main/resources/application-docker.yml @@ -0,0 +1,82 @@ +# Docker 环境配置 +server: + port: ${SERVER_PORT:8100} + +spring: + cloud: + nacos: + discovery: + server-addr: ${NACOS_SERVER_ADDR:nacos:8848} + namespace: fund-platform + group: DEFAULT_GROUP + username: ${NACOS_USERNAME:nacos} + password: ${NACOS_PASSWORD:nacos} + metadata: + tenant-id: ${TENANT_ID:} + + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:fund_platform}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai + username: ${MYSQL_USER:root} + password: ${MYSQL_PASSWORD:root123} + hikari: + maximum-pool-size: 20 + minimum-idle: 5 + connection-timeout: 30000 + idle-timeout: 600000 + max-lifetime: 1800000 + validation-timeout: 5000 + leak-detection-threshold: 60000 + pool-name: FundSysHikariPool + connection-init-sql: SELECT 1 + + data: + redis: + host: ${REDIS_HOST:redis} + port: ${REDIS_PORT:6379} + password: ${REDIS_PASSWORD:} + database: 0 + timeout: 10000 + lettuce: + pool: + max-active: 8 + max-wait: -1 + max-idle: 8 + min-idle: 0 + +mybatis-plus: + mapper-locations: classpath*:/mapper/**/*.xml + type-aliases-package: com.fundplatform.sys.data.entity + configuration: + map-underscore-to-camel-case: true + cache-enabled: false + global-config: + db-config: + logic-delete-field: deleted + logic-delete-value: 1 + logic-not-delete-value: 0 + +logging: + level: + com.fundplatform.sys: INFO + +management: + endpoints: + web: + exposure: + include: health,info,metrics,prometheus + endpoint: + health: + show-details: when_authorized + +tenant: + routing: + enabled: true + tenant-header: X-Tenant-Id + tenant-group-header: X-Tenant-Group + default-tenant-id: "1" + shared-services: + - fund-gateway + - fund-report + - fund-file + fallback-to-shared: true