diff --git a/.gitea/workflows/deploy-web.yaml b/.gitea/workflows/deploy-web.yaml index 02e487d78..ca0035080 100644 --- a/.gitea/workflows/deploy-web.yaml +++ b/.gitea/workflows/deploy-web.yaml @@ -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" diff --git a/Dockerfile b/Dockerfile index f272e5561..5fe11b7c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 版本 diff --git a/apps/web-antd/nginx.conf b/apps/web-antd/nginx.conf index f69f51244..f4eace191 100644 --- a/apps/web-antd/nginx.conf +++ b/apps/web-antd/nginx.conf @@ -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;