Fleet operations analytics (fuel · utilisation · distance · driver behaviour),
sibling to FleetNow. Self-contained src/index.html (inline CSS/JS + Chart.js CDN)
reusing FleetNow's warm-dark ops palette + header shell for a familiar look.
Reads dashboard_api /analytics/* (fleet-summary, utilisation, driver-behaviour,
fuel, filters). Panels: KPI strip, distance/idle daily-trend chart, per-vehicle
table, driver leaderboard, fuel (data-gated).
Served by Caddy on :80 (Traefik terminates TLS). Per-env API base injected at
runtime via Caddy `templates` -> /env.js ({{env "API_BASE"}}); falls back to the
staging API. Dockerfile runs `caddy validate` at build.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
29 lines
882 B
Caddyfile
29 lines
882 B
Caddyfile
# FleetOps — static analytics SPA served by Caddy.
|
|
# Traefik (via Coolify) terminates TLS, so Caddy is a plain :80 file server.
|
|
# The only moving part is runtime API-base injection: Caddy's `templates`
|
|
# directive evaluates {{env "API_BASE"}} inside /env.js at request time, so the
|
|
# SAME image serves staging (fleetapi.fivetitude.com) and prod
|
|
# (fleetapi.rahamafresh.com) — set API_BASE per Coolify app.
|
|
:80 {
|
|
root * /srv
|
|
encode zstd gzip
|
|
|
|
# Health endpoint for Coolify / Traefik probes.
|
|
handle /healthz {
|
|
respond "ok" 200
|
|
}
|
|
|
|
# Runtime config: Caddy renders {{env "API_BASE"}} into env.js. Never cache it.
|
|
handle /env.js {
|
|
templates
|
|
header Cache-Control "no-store"
|
|
file_server
|
|
}
|
|
|
|
# SPA: never cache the shell, fall back to index.html for client routes.
|
|
handle {
|
|
header /index.html Cache-Control "no-store"
|
|
try_files {path} /index.html
|
|
file_server
|
|
}
|
|
}
|