Add Docker configs
This commit is contained in:
12
Dockerfile
Normal file
12
Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM golang:1.24-alpine AS builder
|
||||
WORKDIR /build
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY main.go ./
|
||||
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o ctlog-uptime-exporter .
|
||||
|
||||
FROM scratch
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=builder /build/ctlog-uptime-exporter /ctlog-uptime-exporter
|
||||
EXPOSE 9781
|
||||
ENTRYPOINT ["/ctlog-uptime-exporter"]
|
||||
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
services:
|
||||
ctlog-uptime-exporter:
|
||||
build: .
|
||||
image: git.ipng.ch/ipng/ctlog-uptime-exporter:latest
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "9781:9781"
|
||||
environment:
|
||||
LISTEN: ":9781"
|
||||
URL: "https://www.gstatic.com/ct/compliance/endpoint_uptime_24h.csv"
|
||||
INTERVAL: "25m"
|
||||
JITTER: "5m"
|
||||
28
main.go
28
main.go
@@ -8,6 +8,7 @@ import (
|
||||
"log"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -114,11 +115,30 @@ func (e *exporter) run(csvURL string, interval, jitter time.Duration) {
|
||||
}
|
||||
}
|
||||
|
||||
func envOr(key, def string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
func main() {
|
||||
addr := flag.String("listen", ":9781", "address to listen on")
|
||||
csvURL := flag.String("url", "https://www.gstatic.com/ct/compliance/endpoint_uptime_24h.csv", "URL of the uptime CSV")
|
||||
interval := flag.Duration("interval", 25*time.Minute, "how often to fetch the CSV")
|
||||
jitter := flag.Duration("jitter", 5*time.Minute, "maximum +/-jitter applied to the fetch interval")
|
||||
addr := flag.String("listen", envOr("LISTEN", ":9781"), "address to listen on")
|
||||
csvURL := flag.String("url", envOr("URL", "https://www.gstatic.com/ct/compliance/endpoint_uptime_24h.csv"), "URL of the uptime CSV")
|
||||
interval := flag.Duration("interval", func() time.Duration {
|
||||
d, err := time.ParseDuration(envOr("INTERVAL", "25m"))
|
||||
if err != nil {
|
||||
log.Fatalf("invalid INTERVAL: %v", err)
|
||||
}
|
||||
return d
|
||||
}(), "how often to fetch the CSV")
|
||||
jitter := flag.Duration("jitter", func() time.Duration {
|
||||
d, err := time.ParseDuration(envOr("JITTER", "5m"))
|
||||
if err != nil {
|
||||
log.Fatalf("invalid JITTER: %v", err)
|
||||
}
|
||||
return d
|
||||
}(), "maximum +/-jitter applied to the fetch interval")
|
||||
flag.Parse()
|
||||
|
||||
reg := prometheus.NewRegistry()
|
||||
|
||||
Reference in New Issue
Block a user