From 13c2005282c289195f2f9f8e991b1d8fb56fd97a Mon Sep 17 00:00:00 2001 From: rcourtman Date: Wed, 5 Nov 2025 19:58:05 +0000 Subject: [PATCH] Fix docker agent version not being embedded in binaries The docker agent binaries built in the Dockerfile were missing version information in their ldflags, causing them to always report v4.30.0 (the hardcoded default). This created an update loop where agents would continuously download and restart when checking for updates. The server's /api/agent/version endpoint returns dockeragent.Version, which for the bundled binaries was always v4.30.0 instead of the actual release version (e.g., v4.25.0). When an older agent (e.g., v4.23.0) checked for updates, it would see v4.30.0 available, download it, restart, and repeat the cycle continuously. This fix adds the VERSION file content to the ldflags when building all docker agent binaries (amd64, arm64, armv7), matching the pattern already used in scripts/build-release.sh. Related to #631 --- Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index a439f55..69362ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,22 +54,23 @@ RUN --mount=type=cache,id=pulse-go-mod,target=/go/pkg/mod \ # Build docker-agent binaries (optional cross-arch builds controlled by BUILD_AGENT) RUN --mount=type=cache,id=pulse-go-mod,target=/go/pkg/mod \ --mount=type=cache,id=pulse-go-build,target=/root/.cache/go-build \ + VERSION="v$(cat VERSION | tr -d '\n')" && \ if [ "${BUILD_AGENT:-1}" = "1" ]; then \ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ - -ldflags="-s -w" \ + -ldflags="-s -w -X github.com/rcourtman/pulse-go-rewrite/internal/dockeragent.Version=${VERSION}" \ -trimpath \ -o pulse-docker-agent-linux-amd64 ./cmd/pulse-docker-agent && \ CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build \ - -ldflags="-s -w" \ + -ldflags="-s -w -X github.com/rcourtman/pulse-go-rewrite/internal/dockeragent.Version=${VERSION}" \ -trimpath \ -o pulse-docker-agent-linux-arm64 ./cmd/pulse-docker-agent && \ CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build \ - -ldflags="-s -w" \ + -ldflags="-s -w -X github.com/rcourtman/pulse-go-rewrite/internal/dockeragent.Version=${VERSION}" \ -trimpath \ -o pulse-docker-agent-linux-armv7 ./cmd/pulse-docker-agent; \ else \ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ - -ldflags="-s -w" \ + -ldflags="-s -w -X github.com/rcourtman/pulse-go-rewrite/internal/dockeragent.Version=${VERSION}" \ -trimpath \ -o pulse-docker-agent-linux-amd64 ./cmd/pulse-docker-agent && \ cp pulse-docker-agent-linux-amd64 pulse-docker-agent-linux-arm64 && \