From 9cd769de31bddc6537334ceecaf76ca714e0996f Mon Sep 17 00:00:00 2001 From: tiananlin Date: Fri, 30 Oct 2026 16:13:14 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20Dockerfiles/Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfiles/Dockerfile | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Dockerfiles/Dockerfile diff --git a/Dockerfiles/Dockerfile b/Dockerfiles/Dockerfile new file mode 100644 index 0000000..da89139 --- /dev/null +++ b/Dockerfiles/Dockerfile @@ -0,0 +1,38 @@ +# 构建阶段 +FROM registry-vpc.cn-chengdu.aliyuncs.com/zhixueli-prod/node:22.9.0 AS builder + +# 设置工作目录 +WORKDIR /app + +# 设置 npm 镜像源 +RUN npm config set registry https://registry.npmmirror.com/ +RUN npm config set fetch-retries 3 +RUN npm config set fetch-retry-mintimeout 5000 +RUN npm config set fetch-retry-maxtimeout 60000 + +# 复制 package.json 和 package-lock.json +COPY package.json package-lock.json ./ + +# 安装依赖 +RUN npm install + +# 复制源代码 +COPY . . + +# 构建项目(跳过类型检查) +RUN npm run build + +# 部署阶段 +FROM registry-vpc.cn-chengdu.aliyuncs.com/zhixueli-prod/nginx:alpine + +# 复制构建产物到 Nginx 目录 +COPY --from=builder --chown=nginx:nginx /app/dist /usr/share/nginx/html + +# 复制 Nginx 配置 +COPY Dockerfiles/default.conf /etc/nginx/conf.d/default.conf + +# 暴露端口 +EXPOSE 80 + +# 启动 Nginx +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file From 985e334396085490821d32ce8d70074370b62544 Mon Sep 17 00:00:00 2001 From: tiananlin Date: Fri, 30 Oct 2026 16:13:35 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20Dockerfiles/default.co?= =?UTF-8?q?nf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfiles/default.conf | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Dockerfiles/default.conf diff --git a/Dockerfiles/default.conf b/Dockerfiles/default.conf new file mode 100644 index 0000000..183bcef --- /dev/null +++ b/Dockerfiles/default.conf @@ -0,0 +1,33 @@ +server { + listen 80; + server_name localhost; + + # 基础设置 + root /usr/share/nginx/html; + index index.html index.htm; + + try_files $uri $uri/ /index.html; + + client_max_body_size 100m; + + # 错误页面配置 + error_page 500 502 503 504 /50x.html; + location = /50x.html { + internal; # 仅用于内部错误请求 + } + + # 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 ~* \.(jpg|jpeg|gif|ico|css|js)$ { + expires 7d; + add_header Cache-Control "public, no-transform"; + } +} \ No newline at end of file From 6eccfa166910221b6d1ff6d2c8c1030bb80a4a2e Mon Sep 17 00:00:00 2001 From: tiananlin Date: Fri, 30 Oct 2026 16:20:33 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Dockerfiles/Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfiles/Dockerfile | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Dockerfiles/Dockerfile b/Dockerfiles/Dockerfile index da89139..28c48e1 100644 --- a/Dockerfiles/Dockerfile +++ b/Dockerfiles/Dockerfile @@ -1,5 +1,5 @@ # 构建阶段 -FROM registry-vpc.cn-chengdu.aliyuncs.com/zhixueli-prod/node:22.9.0 AS builder +FROM registry-vpc.cn-chengdu.aliyuncs.com/zhixueli-prod/node:22.15.0 AS builder # 设置工作目录 WORKDIR /app @@ -10,17 +10,23 @@ RUN npm config set fetch-retries 3 RUN npm config set fetch-retry-mintimeout 5000 RUN npm config set fetch-retry-maxtimeout 60000 -# 复制 package.json 和 package-lock.json -COPY package.json package-lock.json ./ +# 安装pnpm +RUN npm install -g pnpm@10.16.1 + +# 复制 package.json +COPY package.json pnpm-lock.yaml ./ + +# 设置 pnpm 下载源 +RUN pnpm config set registry https://registry.npmmirror.com/ # 安装依赖 -RUN npm install +RUN pnpm install --frozen-lockfile # 复制源代码 COPY . . -# 构建项目(跳过类型检查) -RUN npm run build +# 构建项目 +RUN pnpm run build:pro # 部署阶段 FROM registry-vpc.cn-chengdu.aliyuncs.com/zhixueli-prod/nginx:alpine @@ -35,4 +41,4 @@ COPY Dockerfiles/default.conf /etc/nginx/conf.d/default.conf EXPOSE 80 # 启动 Nginx -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +CMD ["nginx", "-g", "daemon off;"] From 20d0c97771fe2d2f63a7b148180a117108081fbf Mon Sep 17 00:00:00 2001 From: tiananlin Date: Fri, 30 Oct 2026 16:21:16 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Dockerfiles/Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfiles/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfiles/Dockerfile b/Dockerfiles/Dockerfile index 28c48e1..0657603 100644 --- a/Dockerfiles/Dockerfile +++ b/Dockerfiles/Dockerfile @@ -13,7 +13,7 @@ RUN npm config set fetch-retry-maxtimeout 60000 # 安装pnpm RUN npm install -g pnpm@10.16.1 -# 复制 package.json +# 复制 package.json 和 pnpm-lock.yaml 文件 COPY package.json pnpm-lock.yaml ./ # 设置 pnpm 下载源 From 84ed71e5b693cbfe258181c726938a35a92a23aa Mon Sep 17 00:00:00 2001 From: tiananlin Date: Fri, 30 Oct 2026 16:31:56 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Dockerfiles/default.co?= =?UTF-8?q?nf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfiles/default.conf | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Dockerfiles/default.conf b/Dockerfiles/default.conf index 183bcef..aacdae0 100644 --- a/Dockerfiles/default.conf +++ b/Dockerfiles/default.conf @@ -30,4 +30,18 @@ server { expires 7d; add_header Cache-Control "public, no-transform"; } + + # API 代理配置 + location /api/ { + proxy_pass http://studyhall-admin-api-service/api/; + 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 300s; + proxy_send_timeout 300s; + proxy_read_timeout 300s; + proxy_buffering on; + } } \ No newline at end of file From e27aaa585015312259a975cdc43be17a504dffe0 Mon Sep 17 00:00:00 2001 From: tiananlin Date: Fri, 30 Oct 2026 16:50:16 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Dockerfiles/default.co?= =?UTF-8?q?nf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfiles/default.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfiles/default.conf b/Dockerfiles/default.conf index aacdae0..9e0c553 100644 --- a/Dockerfiles/default.conf +++ b/Dockerfiles/default.conf @@ -33,7 +33,7 @@ server { # API 代理配置 location /api/ { - proxy_pass http://studyhall-admin-api-service/api/; + proxy_pass http://weibingju-admin-api-svc:5566/api/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;