From 745d6e0fb2ac45401c07b55aedc7fd929dd7be12 Mon Sep 17 00:00:00 2001 From: ngks Date: Fri, 19 Dec 2025 15:21:48 +0800 Subject: [PATCH 01/10] =?UTF-8?q?update:'=E6=B7=BB=E5=8A=A0dockerfile?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E4=BF=AE=E6=94=B9ip'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.prod | 4 ++-- Dockerfile | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/.env.prod b/.env.prod index 1a6841b0..d34e478d 100644 --- a/.env.prod +++ b/.env.prod @@ -4,12 +4,12 @@ NODE_ENV=production VITE_DEV=false # 请求路径 -VITE_BASE_URL='http://192.168.5.119:48081' +VITE_BASE_URL='http://192.168.5.5:48081' # 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持S3服务 VITE_UPLOAD_TYPE=server # 上传路径 -VITE_UPLOAD_URL='http://192.168.5.119:48081/admin-api/infra/file/upload' +VITE_UPLOAD_URL='http://192.168.5.5:48081/admin-api/infra/file/upload' # 接口地址 VITE_API_URL=/admin-api diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..2bb06def --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +# 阶段1: 构建阶段 +FROM node:24.7.0-slim AS builder + +WORKDIR /app + +RUN npm config set registry https://registry.npmmirror.com \ + && npm install -g pnpm \ + && pnpm config set registry https://registry.npmmirror.com + +# 复制依赖文件 +COPY package.json pnpm-lock.yaml ./ + +# 【合并2】强制安装依赖 +RUN pnpm install --force \ + && pnpm add -D @unocss/eslint-plugin + +COPY . . + +# 执行生产构建(和你本地的build:prod命令一致) +RUN pnpm run build:prod + +# 阶段2: 生产运行阶段 +FROM node:24.7.0-slim + +WORKDIR /app + +# 【合并3】设置npm镜像源 + 全局安装pnpm + 设置pnpm镜像源 +RUN npm config set registry https://registry.npmmirror.com \ + && npm install -g pnpm \ + && pnpm config set registry https://registry.npmmirror.com + +COPY --from=builder /app . + +# 设置环境变量 +ENV PORT 8088 +ENV NODE_ENV production + +# 暴露端口 +EXPOSE 8088 + +# 启动应用 +CMD ["pnpm", "start"] \ No newline at end of file From 435549fb3b5bcfc190e784052812bdc4062e1b56 Mon Sep 17 00:00:00 2001 From: ngks Date: Fri, 19 Dec 2025 15:28:08 +0800 Subject: [PATCH 02/10] =?UTF-8?q?update:'=E4=BF=AE=E6=94=B9dockerfile'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Dockerfile b/Dockerfile index 2bb06def..09454dc4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,12 @@ RUN pnpm install --force \ COPY . . +# 【新增关键步骤】创建缺失的cancel.svg文件(解决文件不存在错误) +# 1. 先创建目录(-p确保上级目录不存在时也能创建) +# 2. 写入极简合法的SVG内容,避免Vite报错 +RUN mkdir -p /app/src/assets/svgs/bpm/ \ + && echo '' > /app/src/assets/svgs/bpm/cancel.svg + # 执行生产构建(和你本地的build:prod命令一致) RUN pnpm run build:prod From 390f0dcdb32d4fc678cdc8b02f036d5200224bb4 Mon Sep 17 00:00:00 2001 From: ngks Date: Fri, 19 Dec 2025 15:32:50 +0800 Subject: [PATCH 03/10] =?UTF-8?q?update:'=E4=BF=AE=E6=94=B9dockerfile'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 09454dc4..40d76d14 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,13 +16,17 @@ RUN pnpm install --force \ COPY . . -# 【新增关键步骤】创建缺失的cancel.svg文件(解决文件不存在错误) -# 1. 先创建目录(-p确保上级目录不存在时也能创建) -# 2. 写入极简合法的SVG内容,避免Vite报错 +# 【新增1】创建缺失的cancel.svg文件(解决文件不存在错误) RUN mkdir -p /app/src/assets/svgs/bpm/ \ && echo '' > /app/src/assets/svgs/bpm/cancel.svg -# 执行生产构建(和你本地的build:prod命令一致) +# 【新增2】执行ESLint自动修复(修复vue/no-ref-as-operand错误) +RUN pnpm eslint --fix /app/src/components/Table/src/Table.vue \ + # 可选:修复整个项目的ESLint错误 + # && pnpm eslint --fix /app/src/ + && rm -rf /tmp/* + +# 执行生产构建 RUN pnpm run build:prod # 阶段2: 生产运行阶段 @@ -30,19 +34,15 @@ FROM node:24.7.0-slim WORKDIR /app -# 【合并3】设置npm镜像源 + 全局安装pnpm + 设置pnpm镜像源 RUN npm config set registry https://registry.npmmirror.com \ && npm install -g pnpm \ && pnpm config set registry https://registry.npmmirror.com COPY --from=builder /app . -# 设置环境变量 ENV PORT 8088 ENV NODE_ENV production -# 暴露端口 EXPOSE 8088 -# 启动应用 CMD ["pnpm", "start"] \ No newline at end of file From 3c2f866b3a36728d6365e43c2c7f8b647e2e2df6 Mon Sep 17 00:00:00 2001 From: ngks Date: Fri, 19 Dec 2025 16:09:07 +0800 Subject: [PATCH 04/10] =?UTF-8?q?update:'=E4=BF=AE=E6=94=B9dockerfile'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 40d76d14..f6cf27c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,8 +22,6 @@ RUN mkdir -p /app/src/assets/svgs/bpm/ \ # 【新增2】执行ESLint自动修复(修复vue/no-ref-as-operand错误) RUN pnpm eslint --fix /app/src/components/Table/src/Table.vue \ - # 可选:修复整个项目的ESLint错误 - # && pnpm eslint --fix /app/src/ && rm -rf /tmp/* # 执行生产构建 @@ -45,4 +43,4 @@ ENV NODE_ENV production EXPOSE 8088 -CMD ["pnpm", "start"] \ No newline at end of file +CMD ["pnpm", "vite", "preview", "--port", "8088"] From 8cb04ec42f436ddae32feb1b68b8c909213ae9d2 Mon Sep 17 00:00:00 2001 From: ngks Date: Fri, 19 Dec 2025 16:32:39 +0800 Subject: [PATCH 05/10] =?UTF-8?q?update:'=E4=BF=AE=E6=94=B9dockerfile'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index f6cf27c0..90908a86 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,9 +10,8 @@ RUN npm config set registry https://registry.npmmirror.com \ # 复制依赖文件 COPY package.json pnpm-lock.yaml ./ -# 【合并2】强制安装依赖 RUN pnpm install --force \ - && pnpm add -D @unocss/eslint-plugin + && pnpm add -D @unocss/eslint-plugin@0.57.7 COPY . . @@ -20,12 +19,12 @@ COPY . . RUN mkdir -p /app/src/assets/svgs/bpm/ \ && echo '' > /app/src/assets/svgs/bpm/cancel.svg -# 【新增2】执行ESLint自动修复(修复vue/no-ref-as-operand错误) RUN pnpm eslint --fix /app/src/components/Table/src/Table.vue \ && rm -rf /tmp/* -# 执行生产构建 -RUN pnpm run build:prod +RUN ESLINT_NO_DEV_ERRORS=true pnpm run build:prod + +RUN ls -la /app/ # 阶段2: 生产运行阶段 FROM node:24.7.0-slim @@ -43,4 +42,4 @@ ENV NODE_ENV production EXPOSE 8088 -CMD ["pnpm", "vite", "preview", "--port", "8088"] +CMD ["pnpm", "vite", "preview", "--port", "8088", "--outDir", "dist-prod"] \ No newline at end of file From 09e86abfd988bcf26ad1e5bb13f1894d2efad590 Mon Sep 17 00:00:00 2001 From: ngks Date: Fri, 19 Dec 2025 17:02:01 +0800 Subject: [PATCH 06/10] =?UTF-8?q?update:'=E4=BF=AE=E6=94=B9dockerfile'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 50 +++++++++++++------------------------------------- nginx.conf | 28 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 37 deletions(-) create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index 90908a86..2576e61c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,45 +1,21 @@ -# 阶段1: 构建阶段 -FROM node:24.7.0-slim AS builder +# 构建阶段 +FROM node:20-alpine AS builder WORKDIR /app - -RUN npm config set registry https://registry.npmmirror.com \ - && npm install -g pnpm \ - && pnpm config set registry https://registry.npmmirror.com - -# 复制依赖文件 COPY package.json pnpm-lock.yaml ./ - -RUN pnpm install --force \ - && pnpm add -D @unocss/eslint-plugin@0.57.7 - +RUN npm install -g pnpm +RUN pnpm install COPY . . +RUN pnpm run build:prod # 生成 dist-prod 目录 -# 【新增1】创建缺失的cancel.svg文件(解决文件不存在错误) -RUN mkdir -p /app/src/assets/svgs/bpm/ \ - && echo '' > /app/src/assets/svgs/bpm/cancel.svg - -RUN pnpm eslint --fix /app/src/components/Table/src/Table.vue \ - && rm -rf /tmp/* - -RUN ESLINT_NO_DEV_ERRORS=true pnpm run build:prod - -RUN ls -la /app/ - -# 阶段2: 生产运行阶段 -FROM node:24.7.0-slim - -WORKDIR /app - -RUN npm config set registry https://registry.npmmirror.com \ - && npm install -g pnpm \ - && pnpm config set registry https://registry.npmmirror.com - -COPY --from=builder /app . +# 运行阶段 +FROM nginx:alpine -ENV PORT 8088 -ENV NODE_ENV production +# 关键:复制的是 dist-prod 而不是 dist +COPY --from=builder /app/dist-prod /usr/share/nginx/html -EXPOSE 8088 +# 复制 Nginx 配置(确保这个文件存在) +COPY nginx.conf /etc/nginx/nginx.conf -CMD ["pnpm", "vite", "preview", "--port", "8088", "--outDir", "dist-prod"] \ No newline at end of file +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 00000000..050079a3 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,28 @@ +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html; + try_files $uri $uri/ /index.html; + } + + # 代理 API 请求到后端容器 + location /api { + proxy_pass http://besure_server:48081; # ← Docker Compose 服务名 + 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; + } + } +} \ No newline at end of file From 2cedd6404d5c6276b168d7605341c7932a21086a Mon Sep 17 00:00:00 2001 From: ngks Date: Fri, 19 Dec 2025 17:06:47 +0800 Subject: [PATCH 07/10] =?UTF-8?q?update:'=E4=BF=AE=E6=94=B9dockerfile'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2576e61c..3ad3359d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,19 +2,29 @@ FROM node:20-alpine AS builder WORKDIR /app + +# 复制依赖清单 COPY package.json pnpm-lock.yaml ./ -RUN npm install -g pnpm -RUN pnpm install + +# 设置 npm 和 pnpm 使用国内镜像源(关键!) +RUN npm config set registry https://registry.npmmirror.com && \ + npm install -g pnpm && \ + pnpm config set registry https://registry.npmmirror.com + +# 安装依赖(现在会走淘宝镜像) +RUN pnpm install --frozen-lockfile + +# 复制源码并构建 COPY . . RUN pnpm run build:prod # 生成 dist-prod 目录 # 运行阶段 FROM nginx:alpine -# 关键:复制的是 dist-prod 而不是 dist +# 复制前端产物 COPY --from=builder /app/dist-prod /usr/share/nginx/html -# 复制 Nginx 配置(确保这个文件存在) +# 复制 Nginx 配置 COPY nginx.conf /etc/nginx/nginx.conf EXPOSE 80 From f4dabf563b8da607d832019811f441deb144c73b Mon Sep 17 00:00:00 2001 From: ngks Date: Sun, 21 Dec 2025 15:53:34 +0800 Subject: [PATCH 08/10] =?UTF-8?q?update:=E6=B7=BB=E5=8A=A0=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/svgs/bpm/cancel.svg | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/assets/svgs/bpm/cancel.svg diff --git a/src/assets/svgs/bpm/cancel.svg b/src/assets/svgs/bpm/cancel.svg new file mode 100644 index 00000000..8ff3bba6 --- /dev/null +++ b/src/assets/svgs/bpm/cancel.svg @@ -0,0 +1 @@ + \ No newline at end of file From 679cf6addc83d6e3a0722237cdea6cf071537ccd Mon Sep 17 00:00:00 2001 From: ngks Date: Sun, 21 Dec 2025 16:17:38 +0800 Subject: [PATCH 09/10] =?UTF-8?q?update:'=E4=BF=AE=E6=94=B9dockerfile'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3ad3359d..e00fe98d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,31 +1,21 @@ -# 构建阶段 -FROM node:20-alpine AS builder - -WORKDIR /app - -# 复制依赖清单 -COPY package.json pnpm-lock.yaml ./ - -# 设置 npm 和 pnpm 使用国内镜像源(关键!) -RUN npm config set registry https://registry.npmmirror.com && \ - npm install -g pnpm && \ - pnpm config set registry https://registry.npmmirror.com - -# 安装依赖(现在会走淘宝镜像) -RUN pnpm install --frozen-lockfile +# 使用轻量级的 Nginx 镜像 +FROM nginx:alpine -# 复制源码并构建 -COPY . . -RUN pnpm run build:prod # 生成 dist-prod 目录 +# 复制自定义 Nginx 配置(如果有) +RUN rm -f /etc/nginx/conf.d/default.conf +COPY nginx.conf /etc/nginx/conf.d/default.conf -# 运行阶段 -FROM nginx:alpine +# 将本地 dist 目录复制到容器中 +COPY dist /usr/share/nginx/html -# 复制前端产物 -COPY --from=builder /app/dist-prod /usr/share/nginx/html +# 暴露 8088 端口 +EXPOSE 8088 -# 复制 Nginx 配置 -COPY nginx.conf /etc/nginx/nginx.conf +# 创建启动脚本 +RUN echo -e '#!/bin/sh\n\ +echo "Waiting for MySQL/Redis/MinIO to start..."\n\ +sleep 15\n\ +nginx -g "daemon off;"' > /start.sh && \ + chmod +x /start.sh -EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +CMD ["/start.sh"] \ No newline at end of file From 70ea24eb843c6e52ff012d7b4354e798deeac703 Mon Sep 17 00:00:00 2001 From: ngks Date: Sun, 21 Dec 2025 16:20:45 +0800 Subject: [PATCH 10/10] =?UTF-8?q?update:'=E4=BF=AE=E6=94=B9nginx=E9=85=8D?= =?UTF-8?q?=E7=BD=AE'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nginx.conf | 114 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 88 insertions(+), 26 deletions(-) diff --git a/nginx.conf b/nginx.conf index 050079a3..bdab8a00 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,28 +1,90 @@ -events { - worker_connections 1024; -} - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - server { - listen 80; - server_name localhost; - - location / { - root /usr/share/nginx/html; - index index.html; - try_files $uri $uri/ /index.html; - } - - # 代理 API 请求到后端容器 - location /api { - proxy_pass http://besure_server:48081; # ← Docker Compose 服务名 - 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; - } +server { + listen 8088; + server_name localhost; + + location /admin-api/ { + proxy_pass http://besure_server:48081; + 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_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + + location /api/ { + proxy_pass http://besure_server:48081; + 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_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + + location /jmreport/ { + proxy_pass http://besure_server:48081; + 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_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + + location /v3/api-docs/ { + proxy_pass http://besure_server:48081; + 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_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + + location /doc.html { + proxy_pass http://besure_server:48081; + 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_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + + location /swagger-ui/ { + proxy_pass http://besure_server:48081; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + # 处理Swagger静态资源 + location /webjars/ { + proxy_pass http://besure_server:48081; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + # 处理API文档JSON文件 + location ~ /v3/api-docs/.*\.json$ { + proxy_pass http://besure_server:48081; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; } } \ No newline at end of file