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
This commit is contained in:
parent
dc94f6092a
commit
13c2005282
1 changed files with 5 additions and 4 deletions
|
|
@ -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 && \
|
||||
|
|
|
|||
Loading…
Reference in a new issue