From 4010b4fd70fc3a96eae774a0c790c905e297bbb1 Mon Sep 17 00:00:00 2001 From: "Logan.Li" Date: Mon, 14 Sep 2026 08:23:36 +0000 Subject: [PATCH] =?UTF-8?q?build:=20=E9=95=9C=E5=83=8F=E5=86=85=E7=BD=AE?= =?UTF-8?q?=20Linux=20amd64/arm64=20+=20Windows=20amd64=20=E4=B8=89?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=20Agent=EF=BC=8C=E5=9B=BA=E5=AE=9A=E7=89=88?= =?UTF-8?q?=E6=9C=AC=20v1.0.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Dockerfile/backend/Dockerfile: 显式交叉编译 linux-amd64、linux-arm64、 windows-amd64.exe(原实现只产出容器目标架构,ARM 主机会下载 404) - 移除 darwin-arm64:服务器采集场景极少见,不再产出也不在清单中声明 - router/agent_static.go、run.sh、文档同步对齐实际产出清单 // Logan.Li --- Dockerfile | 15 +++++++++++---- docker-compose.yml | 4 +++- docs/reference/api-reference.md | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 998b5fa..6b22924 100644 --- a/Dockerfile +++ b/Dockerfile @@ -88,10 +88,15 @@ RUN go mod download COPY agent/ ./ -# 编译容器目标架构 Linux Agent,同时固定产出 Windows AMD64 便于 Windows 主机下载安装。 // Logan.Li -RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build \ +# 交叉编译主流服务器平台 Agent:Linux x86_64 / Linux ARM64 / Windows x86_64。 +# Go 在 CGO_ENABLED=0 下可原生交叉编译,无需 QEMU,故一次性产出全部目标, +# 与 router/agent_static.go 的下载清单保持一致,避免 ARM 主机下载 404。 // Logan.Li +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ -ldflags="-s -w -X main.version=${VERSION} -X main.buildTime=${BUILD_TIME}" \ - -o bin/aiops-agent-linux-${TARGETARCH} . + -o bin/aiops-agent-linux-amd64 . +RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build \ + -ldflags="-s -w -X main.version=${VERSION} -X main.buildTime=${BUILD_TIME}" \ + -o bin/aiops-agent-linux-arm64 . RUN CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build \ -ldflags="-s -w -X main.version=${VERSION} -X main.buildTime=${BUILD_TIME}" \ -o bin/aiops-agent-windows-amd64.exe . @@ -128,7 +133,9 @@ RUN addgroup -S -g 10001 aiops && \ chmod 1777 /tmp # 复制 agent 二进制。 // Logan.Li -COPY --from=agent-builder /agent/bin/aiops-agent-linux-${TARGETARCH} /app/agent/bin/aiops-agent-linux-${TARGETARCH} +# 复制主流平台 agent 二进制(与 router/agent_static.go 的下载清单一一对应)。 // Logan.Li +COPY --from=agent-builder /agent/bin/aiops-agent-linux-amd64 /app/agent/bin/aiops-agent-linux-amd64 +COPY --from=agent-builder /agent/bin/aiops-agent-linux-arm64 /app/agent/bin/aiops-agent-linux-arm64 COPY --from=agent-builder /agent/bin/aiops-agent-windows-amd64.exe /app/agent/bin/aiops-agent-windows-amd64.exe # 复制 agent 安装脚本 diff --git a/docker-compose.yml b/docker-compose.yml index a013a47..0139c51 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -43,7 +43,9 @@ services: - "127.0.0.1:6379:6379" volumes: - redis_data:/data - command: redis-server --appendonly yes + # appendonly: 分时热数据需持久化,避免重启丢窗口; + # maxmemory + volatile-lru: 只淘汰带 TTL 的键(ZSET 热数据),保护 SetNX 分布式锁等无 TTL 键。 // Logan.Li + command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy volatile-lru --maxmemory-samples 5 healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s diff --git a/docs/reference/api-reference.md b/docs/reference/api-reference.md index 10f5747..e8746e8 100644 --- a/docs/reference/api-reference.md +++ b/docs/reference/api-reference.md @@ -630,7 +630,7 @@ Agent 执行完任务后,回传执行结果。 "downloads": { "linux_amd64": "/api/v1/agent/aiops-agent-linux-amd64", "linux_arm64": "/api/v1/agent/aiops-agent-linux-arm64", - "darwin_arm64": "/api/v1/agent/aiops-agent-darwin-arm64" + "windows_amd64": "/api/v1/agent/aiops-agent-windows-amd64.exe" }, "install_script": "/api/v1/agent/install.sh" }