A modern HTTP service for tracking build start and finish times in CI/CD pipelines with web dashboard, metrics, and dual storage modes.
/metrics
endpoint with detailed application metrics/health
, /healthz
, /readyz
endpoints for KubernetesThe build counter includes a modern web dashboard accessible at http://localhost:8080/
:
Main Dashboard:
Features by Mode:
Prerequisites:
Setup:
# 1. Create database schema
psql -d your_db -f builds.sql
# 2. Set database connection
export DATABASE_URL="postgres://user:password@localhost:5432/builddb?sslmode=disable"
# 3. Run the service
./build-counter
# or
make run
Prerequisites:
Setup:
# Set Kubernetes namespace (optional)
export NAMESPACE="your-namespace"
export CONFIGMAP_NAME="build-counter"
# Run in lightweight mode
./build-counter --lightweight
# Pull from GitHub Container Registry (recommended)
docker pull ghcr.io/rossigee/build-counter:latest
# Or from Docker Hub
docker pull rossigee/build-counter:latest
# Run in database mode
docker run -p 8080:8080 \
-e DATABASE_URL="postgres://user:pass@host:5432/db" \
ghcr.io/rossigee/build-counter:latest
# Run in lightweight mode
docker run -p 8080:8080 \
-v ~/.kube/config:/root/.kube/config \
-e NAMESPACE="default" \
ghcr.io/rossigee/build-counter:latest --lightweight
build-counter [options]
Options:
--version Show version information
--help Show help message
--lightweight Use Kubernetes ConfigMap storage
--health-check Check if service is healthy
# Start a build
curl -X POST "http://localhost:8080/start?name=my-project&build_id=abc123"
# Response: {"next_id": 42}
# Finish a build
curl -X POST "http://localhost:8080/finish?name=my-project&build_id=abc123"
# Response: HTTP 201 Created
# Get all projects (JSON)
curl http://localhost:8080/api/projects
# Get builds for a project (JSON)
curl "http://localhost:8080/api/projects?name=my-project"
# Web dashboard
open http://localhost:8080/
# Health check
curl http://localhost:8080/health
# Kubernetes probes
curl http://localhost:8080/healthz # Liveness
curl http://localhost:8080/readyz # Readiness
# Prometheus metrics
curl http://localhost:8080/metrics
Variable | Description | Required | Default |
---|---|---|---|
DATABASE_URL |
PostgreSQL connection string | Yes (database mode) | - |
NAMESPACE |
Kubernetes namespace | No | default |
CONFIGMAP_NAME |
ConfigMap name | No | build-counter |
# Enable OTLP tracing
export OTEL_EXPORTER_OTLP_ENDPOINT="http://jaeger:4318"
export OTEL_SERVICE_NAME="build-counter"
export OTEL_SERVICE_VERSION="1.0.0"
# For insecure connections
export OTEL_EXPORTER_OTLP_INSECURE="true"
# Build binary
make build
# Run tests
make test
# Run with hot reload
make run
# Build Docker image
make image
# Install development dependencies
make dev-deps
# Run linting
make lint
# Format code
make fmt
# Security scan
make sec
# Install pre-commit
pip install pre-commit
# Install hooks
pre-commit install
# Run manually
pre-commit run --all-files
The /metrics
endpoint provides Prometheus-compatible metrics:
build_counter_requests_total
- Total HTTP requestsbuild_counter_builds_started_total
- Total builds startedbuild_counter_builds_finished_total
- Total builds finishedbuild_counter_errors_total
- Total errorsbuild_counter_uptime_seconds
- Service uptimebuild_counter_memory_usage_bytes
- Memory usage# Add Helm repository
helm repo add build-counter https://rossigee.github.io/build-counter
helm repo update
# Install with database mode (default)
helm install my-build-counter build-counter/build-counter \
--set storage.database.url="postgres://user:pass@host:5432/db"
# Install with lightweight mode
helm install my-build-counter build-counter/build-counter \
--set storage.mode=lightweight
# Install from GitHub Container Registry (OCI)
helm install my-build-counter oci://ghcr.io/rossigee/helm/build-counter \
--version 1.0.0
See the Helm chart documentation for all configuration options.
apiVersion: apps/v1
kind: Deployment
metadata:
name: build-counter
spec:
replicas: 2
selector:
matchLabels:
app: build-counter
template:
metadata:
labels:
app: build-counter
spec:
containers:
- name: build-counter
image: ghcr.io/rossigee/build-counter:latest
ports:
- containerPort: 8080
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: build-counter-secret
key: database-url
livenessProbe:
httpGet:
path: /healthz
port: 8080
readinessProbe:
httpGet:
path: /readyz
port: 8080
apiVersion: v1
kind: ServiceAccount
metadata:
name: build-counter
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: build-counter
rules:
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "list", "create", "update", "patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: build-counter
subjects:
- kind: ServiceAccount
name: build-counter
roleRef:
kind: Role
name: build-counter
apiGroup: rbac.authorization.k8s.io
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: build-counter
spec:
replicas: 1
selector:
matchLabels:
app: build-counter
template:
metadata:
labels:
app: build-counter
spec:
serviceAccountName: build-counter
containers:
- name: build-counter
image: ghcr.io/rossigee/build-counter:latest
args: ["--lightweight"]
ports:
- containerPort: 8080
env:
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
git checkout -b feature/amazing-feature
)make test
)make lint
)git commit -m 'Add amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.