feat: show build date on agent startup

Inject build timestamp via ldflags during Docker build so the
agent logs when the binary was compiled.
This commit is contained in:
Graham McIntire 2026-03-24 12:56:11 -05:00
parent 1ba8e085a7
commit abde949455
No known key found for this signature in database
2 changed files with 3 additions and 2 deletions

View file

@ -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

View file

@ -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)