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:
parent
1ba8e085a7
commit
abde949455
2 changed files with 3 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
3
main.go
3
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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue