fix: agent install.sh 404 + 三阶段构建编译agent二进制

问题: 构建上下文 ./backend 无法访问 ../agent, 导致容器内
/app/agent/deploy/install.sh 不存在, 返回 404

修复:
- Dockerfile 改为三阶段构建 (backend go1.21 + agent go1.24 交叉编译 + alpine runtime)
- docker-compose backend build context 改为项目根
- routes.go /agent/arch 安装命令改为动态获取 URL
- 新增 .dockerignore
- agent_install.go: SSH 远程安装 handler
- AgentWizard.tsx: 复制按钮 fallback + 动态 server URL
- ServerTableRow.tsx: agent 状态判断

验证: curl|bash 安装成功, agent 上报数据到 MySQL ✅
This commit is contained in:
Logan committed 2026-06-18 09:44:12 +08:00
1 parent d0344c2f52
commit d0b94d39c0
9 files changed
+281 -38

No files matched your search

+4
View File
@@ -143,6 +143,10 @@ export const serverApi = {
// 后端暂无单机 metrics,用 dashboard metrics
return http.get('/dashboard/metrics');
},
// 远程安装 Agent(通过 SSH 执行安装脚本)
installAgent: async (id: number | string, token: string) => {
return http.post<{ installed: boolean; arch: string; output: string }>(`/servers/${id}/install-agent?token=${encodeURIComponent(token)}`);
},
};
// ==================== K8s 集群 API ====================