fix: 优化构建速度,后端容器名
All checks were successful
Web UI CI/CD / build-and-deploy (push) Successful in 3m31s

This commit is contained in:
lzh
2025-12-18 14:03:54 +08:00
parent 1c04ff0d7b
commit 874c06fa51
3 changed files with 21 additions and 6 deletions

View File

@@ -66,7 +66,8 @@ jobs:
# 使用根目录的 Dockerfile 进行构建
# Dockerfile 内部使用了多阶段构建,不需要 Runner 安装 Node
docker build -t "$FULL_IMAGE_NAME" -f Dockerfile .
# 启用 BuildKit 以支持缓存挂载(加速依赖安装)
DOCKER_BUILDKIT=1 docker build -t "$FULL_IMAGE_NAME" -f Dockerfile .
# 打上 latest 标签
docker tag "$FULL_IMAGE_NAME" "${IMAGE_NAME}:latest"

View File

@@ -28,8 +28,11 @@ COPY apps apps
COPY internal internal
# 安装依赖
# 使用 --frozen-lockfile 确保版本一致
RUN pnpm install --frozen-lockfile
# 使用 BuildKit 缓存挂载加速依赖安装
# 缓存 pnpm store即使 package.json 变了,已下载的包也能复用
# pnpm store 默认路径:~/.local/share/pnpm/store (Linux)
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile
# 构建指定项目 (根据 package.json 里的 scripts)
# 这里我们构建 antd 版本

View File

@@ -14,10 +14,21 @@ server {
index index.html;
# API 反向代理到后端服务
# 如果后端在 Docker 容器中,使用容器名http://aiot-server:48080
# 如果后端在宿主机上,使用内网地址http://172.17.16.14:48080 或 http://172.17.0.1:48080
# 后端服务在 Docker 容器中,使用容器名访问(都在 aiot-net 网络中)
# 如果后端在宿主机上,改为http://172.17.0.1:48080/admin-api
location /admin-api {
proxy_pass http://172.17.16.14:48080/admin-api;
# 后端服务地址(根据实际情况选择)
# 方案1后端在 Docker 容器中(推荐)
proxy_pass http://aiot-server:48080/admin-api;
# 方案2后端在宿主机上取消注释下面这行并注释掉上面那行
# proxy_pass http://172.17.0.1:48080/admin-api;
# 代理超时设置
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
# 代理请求头
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;