Include the version in the initial log output
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
parent
bfe1115cb5
commit
15625050c7
2
.github/workflows/docker.yaml
vendored
2
.github/workflows/docker.yaml
vendored
@ -37,3 +37,5 @@ jobs:
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args:
|
||||
VERSION: ${{ steps.meta.outputs.version }}
|
||||
|
@ -4,6 +4,7 @@ ARG TARGETPLATFORM
|
||||
ARG BUILDPLATFORM
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
ARG VERSION="dev"
|
||||
|
||||
RUN apk update && apk add -U --no-cache ca-certificates
|
||||
|
||||
@ -12,7 +13,7 @@ ADD go.mod go.sum ./
|
||||
RUN go mod download
|
||||
ADD main.go .
|
||||
ADD pkg/ ./pkg
|
||||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s" -o tailscale-exporter main.go
|
||||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s -X 'main.Version=${VERSION}'" -o tailscale-exporter main.go
|
||||
|
||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} scratch
|
||||
WORKDIR /app/
|
||||
|
3
main.go
3
main.go
@ -11,6 +11,7 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
|
||||
var Version = "dev"
|
||||
var addr string
|
||||
|
||||
func init() {
|
||||
@ -32,7 +33,7 @@ func main() {
|
||||
metrics.Collect(client, reg)
|
||||
|
||||
http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{Registry: reg}))
|
||||
log.Printf("tailscale-exporter")
|
||||
log.Printf("tailscale-exporter - %s", Version)
|
||||
log.Printf("Listening on %s", addr)
|
||||
log.Fatal(http.ListenAndServe(addr, nil))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user