From abde949455c9827fcf4ec6deb15bb394765d5ee4 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Tue, 24 Mar 2026 12:56:11 -0500 Subject: [PATCH] feat: show build date on agent startup Inject build timestamp via ldflags during Docker build so the agent logs when the binary was compiled. --- Dockerfile | 2 +- main.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e32430d..58f07f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ COPY . . ARG VERSION=dev RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ - CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=${VERSION}" -o towerops-agent . + CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=${VERSION} -X main.buildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o towerops-agent . FROM alpine:3.23 RUN apk add --no-cache ca-certificates iputils libcap diff --git a/main.go b/main.go index a83d9ff..edef54d 100644 --- a/main.go +++ b/main.go @@ -13,6 +13,7 @@ import ( ) var version = "dev" +var buildDate = "unknown" var insecureFlag bool @@ -71,7 +72,7 @@ func runMain(ctx context.Context, args []string) int { return 1 } - slog.Info("towerops agent starting", "version", version) + slog.Info("towerops agent starting", "version", version, "built", buildDate) // Convert HTTP(S) to WebSocket URL wsURL, err := toWebSocketURL(*apiURL)