From c73dd10f9cf2cb3a53a133bdb73c1b42a9ee305c Mon Sep 17 00:00:00 2001 From: JianFeeeee Date: Wed, 2 Sep 2026 10:32:41 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E4=BF=9D=E7=95=99=20go:embed=20?= =?UTF-8?q?=E5=8D=A0=E4=BD=8D=E9=A1=B5=EF=BC=8C=E6=96=B0=E5=85=8B=E9=9A=86?= =?UTF-8?q?=E6=97=A0=E9=9C=80=20node=20=E5=8D=B3=E5=8F=AF=E7=BC=96?= =?UTF-8?q?=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit go:embed 要求目标目录存在才能编译,而构建产物不进版本库 —— 上一版把整个 gateway/internal/static/static/ 忽略掉,导致新克隆连 go build ./cmd/server 都跑不起来(pattern static: no matching files found), 只改后端的人被迫先装 node。 改为忽略目录内容但保留一个占位 index.html:说明前端未构建、给出构建命令, 并明确后端 API 仍然可用。真实产物由 install.sh 覆盖后嵌入。 --- .gitignore | 9 ++- gateway/internal/static/static/index.html | 69 +++++++++++++++++++++++ 2 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 gateway/internal/static/static/index.html diff --git a/.gitignore b/.gitignore index 9723b21..1f91c3b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,9 +9,12 @@ web/dist/ plugins/*/node_modules/ # go:embed 的输入目录 = web/dist 的副本,同属构建产物。 -# 注意 embed 要求目录存在才能编译,克隆后需先跑一次 -# `deploy/install.sh`(或 npm run build && cp -r web/dist ...)。 -gateway/internal/static/static/ +# +# 但目录本身要留下:go:embed 要求它存在才能编译,否则新克隆连 +# `go test ./...` 都跑不起来 —— 只改后端的人不该被迫先装 node。 +# 因此忽略里面的产物,只保留一个占位 index.html(见该文件内注释)。 +gateway/internal/static/static/* +!gateway/internal/static/static/index.html # Go 构建产物 gateway/agentmail-gateway diff --git a/gateway/internal/static/static/index.html b/gateway/internal/static/static/index.html new file mode 100644 index 0000000..41b402a --- /dev/null +++ b/gateway/internal/static/static/index.html @@ -0,0 +1,69 @@ + + + + + + + AgentMail — 前端未构建 + + + +
+

AgentMail 前端未构建

+

+ 当前二进制里嵌入的是占位页。后端 API 仍然可用(/api/v1、 + /health)。 +

+

构建并嵌入前端:

+
sudo ./deploy/install.sh
+

或者手工:

+
cd web && npm ci && npm run build
+rm -rf ../gateway/internal/static/static
+cp -r dist ../gateway/internal/static/static
+cd ../gateway && go build ./cmd/server
+

+ 构建产物不进版本库;这个占位文件的存在只是为了让 + go:embed 在新克隆里能编译通过。 +

+
+ +