2026-04-07 18:34:40 +00:00
|
|
|
services:
|
|
|
|
|
timescale_db:
|
2026-04-08 14:17:58 +00:00
|
|
|
image: timescale/timescaledb-ha:pg16-ts2.15
|
2026-04-07 18:34:40 +00:00
|
|
|
restart: always
|
|
|
|
|
environment:
|
|
|
|
|
- POSTGRES_DB=${POSTGRES_DB}
|
|
|
|
|
- POSTGRES_USER=${POSTGRES_USER}
|
|
|
|
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
2026-04-24 07:59:53 +00:00
|
|
|
# HA image's PGDATA is /home/postgres/pgdata/data, not /var/lib/postgresql/data.
|
|
|
|
|
# Mount the named volume there so data survives container rebuilds.
|
|
|
|
|
- PGDATA=/home/postgres/pgdata/data
|
2026-04-18 11:14:32 +00:00
|
|
|
ports:
|
2026-07-02 06:51:02 +00:00
|
|
|
# SEC-01: default to loopback-only — the DB must not listen on the public
|
|
|
|
|
# internet (services reach it over the internal Docker network; local
|
|
|
|
|
# tooling uses an SSH tunnel: `ssh -L 5433:localhost:5433 <host>`).
|
|
|
|
|
# Set DB_BIND_ADDR=0.0.0.0 in .env only if you deliberately re-expose it.
|
|
|
|
|
- "${DB_BIND_ADDR:-127.0.0.1}:5433:5432"
|
2026-04-07 18:34:40 +00:00
|
|
|
volumes:
|
2026-04-24 07:59:53 +00:00
|
|
|
- timescale-data:/home/postgres/pgdata
|
2026-04-07 18:34:40 +00:00
|
|
|
healthcheck:
|
|
|
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
|
|
|
|
interval: 10s
|
|
|
|
|
timeout: 5s
|
|
|
|
|
retries: 5
|
|
|
|
|
|
2026-06-10 18:41:05 +00:00
|
|
|
ingest_worker:
|
|
|
|
|
# Merged movement + events pollers (was ingest_movement + ingest_events).
|
|
|
|
|
# Both pipelines run in one process via ingest_worker_rev.py — same image,
|
|
|
|
|
# same shared connection pool, one `schedule` loop. See ingest_worker_rev.py.
|
Add webhook receiver, consolidate shared utilities, expand telemetry coverage
- Add FastAPI webhook receiver (webhook_receiver_rev.py) for Jimi push data:
OBD diagnostics, DTC fault codes, alarms, GPS, heartbeats, trip reports
- Add schema migration (03_webhook_schema_migration.sql) for webhook tables:
fault_codes, heartbeats, expanded obd_readings/trips/position_history/alarms
- Consolidate duplicated _safe/_shutdown into shared safe_task/setup_shutdown
in ts_shared_rev.py (DRY refactor)
- Add auto-commit to get_conn() context manager (prevents forgotten commits)
- Fix poll_trips to capture runTimeSecond and maxSpeed from API
- Add poll_parking via jimi.open.platform.report.parking
- Remove broken poll_obd (OBD is push-only, no polling endpoint exists)
- Fix alarms schema: add lat/lng/acc_status columns + dedup constraint
- Fix obd_readings schema: add dedup constraint
- Fix trigger DO block: replace nonexistent has_column with information_schema
- Narrow api_post exception handling to RequestException/ValueError
- Add webhook_receiver service to docker-compose.yaml
- Add fastapi/uvicorn/python-multipart to pyproject.toml
- Add clean_ts timestamp validator to ts_shared_rev.py
- Add Tracksolid Pro API documentation (tracksolidApiDocumentation.md)
- Populate .gitignore with Python/OS/secrets patterns
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 13:28:45 +00:00
|
|
|
build:
|
2026-04-07 18:34:40 +00:00
|
|
|
context: .
|
|
|
|
|
dockerfile: Dockerfile
|
2026-06-10 18:41:05 +00:00
|
|
|
command: sh -c "python run_migrations.py && python ingest_worker_rev.py"
|
2026-04-07 18:34:40 +00:00
|
|
|
restart: always
|
|
|
|
|
depends_on:
|
2026-04-08 14:11:12 +00:00
|
|
|
timescale_db:
|
|
|
|
|
condition: service_healthy
|
Add webhook receiver, consolidate shared utilities, expand telemetry coverage
- Add FastAPI webhook receiver (webhook_receiver_rev.py) for Jimi push data:
OBD diagnostics, DTC fault codes, alarms, GPS, heartbeats, trip reports
- Add schema migration (03_webhook_schema_migration.sql) for webhook tables:
fault_codes, heartbeats, expanded obd_readings/trips/position_history/alarms
- Consolidate duplicated _safe/_shutdown into shared safe_task/setup_shutdown
in ts_shared_rev.py (DRY refactor)
- Add auto-commit to get_conn() context manager (prevents forgotten commits)
- Fix poll_trips to capture runTimeSecond and maxSpeed from API
- Add poll_parking via jimi.open.platform.report.parking
- Remove broken poll_obd (OBD is push-only, no polling endpoint exists)
- Fix alarms schema: add lat/lng/acc_status columns + dedup constraint
- Fix obd_readings schema: add dedup constraint
- Fix trigger DO block: replace nonexistent has_column with information_schema
- Narrow api_post exception handling to RequestException/ValueError
- Add webhook_receiver service to docker-compose.yaml
- Add fastapi/uvicorn/python-multipart to pyproject.toml
- Add clean_ts timestamp validator to ts_shared_rev.py
- Add Tracksolid Pro API documentation (tracksolidApiDocumentation.md)
- Populate .gitignore with Python/OS/secrets patterns
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 13:28:45 +00:00
|
|
|
env_file: .env
|
|
|
|
|
|
|
|
|
|
webhook_receiver:
|
|
|
|
|
build:
|
|
|
|
|
context: .
|
|
|
|
|
dockerfile: Dockerfile
|
2026-04-08 15:54:42 +00:00
|
|
|
command: sh -c "python run_migrations.py && uvicorn webhook_receiver_rev:app --host 0.0.0.0 --port 8888 --workers 2"
|
Add webhook receiver, consolidate shared utilities, expand telemetry coverage
- Add FastAPI webhook receiver (webhook_receiver_rev.py) for Jimi push data:
OBD diagnostics, DTC fault codes, alarms, GPS, heartbeats, trip reports
- Add schema migration (03_webhook_schema_migration.sql) for webhook tables:
fault_codes, heartbeats, expanded obd_readings/trips/position_history/alarms
- Consolidate duplicated _safe/_shutdown into shared safe_task/setup_shutdown
in ts_shared_rev.py (DRY refactor)
- Add auto-commit to get_conn() context manager (prevents forgotten commits)
- Fix poll_trips to capture runTimeSecond and maxSpeed from API
- Add poll_parking via jimi.open.platform.report.parking
- Remove broken poll_obd (OBD is push-only, no polling endpoint exists)
- Fix alarms schema: add lat/lng/acc_status columns + dedup constraint
- Fix obd_readings schema: add dedup constraint
- Fix trigger DO block: replace nonexistent has_column with information_schema
- Narrow api_post exception handling to RequestException/ValueError
- Add webhook_receiver service to docker-compose.yaml
- Add fastapi/uvicorn/python-multipart to pyproject.toml
- Add clean_ts timestamp validator to ts_shared_rev.py
- Add Tracksolid Pro API documentation (tracksolidApiDocumentation.md)
- Populate .gitignore with Python/OS/secrets patterns
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 13:28:45 +00:00
|
|
|
restart: always
|
|
|
|
|
depends_on:
|
2026-04-08 14:11:12 +00:00
|
|
|
timescale_db:
|
|
|
|
|
condition: service_healthy
|
Add webhook receiver, consolidate shared utilities, expand telemetry coverage
- Add FastAPI webhook receiver (webhook_receiver_rev.py) for Jimi push data:
OBD diagnostics, DTC fault codes, alarms, GPS, heartbeats, trip reports
- Add schema migration (03_webhook_schema_migration.sql) for webhook tables:
fault_codes, heartbeats, expanded obd_readings/trips/position_history/alarms
- Consolidate duplicated _safe/_shutdown into shared safe_task/setup_shutdown
in ts_shared_rev.py (DRY refactor)
- Add auto-commit to get_conn() context manager (prevents forgotten commits)
- Fix poll_trips to capture runTimeSecond and maxSpeed from API
- Add poll_parking via jimi.open.platform.report.parking
- Remove broken poll_obd (OBD is push-only, no polling endpoint exists)
- Fix alarms schema: add lat/lng/acc_status columns + dedup constraint
- Fix obd_readings schema: add dedup constraint
- Fix trigger DO block: replace nonexistent has_column with information_schema
- Narrow api_post exception handling to RequestException/ValueError
- Add webhook_receiver service to docker-compose.yaml
- Add fastapi/uvicorn/python-multipart to pyproject.toml
- Add clean_ts timestamp validator to ts_shared_rev.py
- Add Tracksolid Pro API documentation (tracksolidApiDocumentation.md)
- Populate .gitignore with Python/OS/secrets patterns
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 13:28:45 +00:00
|
|
|
env_file: .env
|
2026-04-08 13:49:52 +00:00
|
|
|
# No host port binding — Coolify's Traefik proxy routes traffic internally.
|
2026-04-08 15:54:42 +00:00
|
|
|
# Set the webhook domain in Coolify UI pointing to this service on port 8888.
|
Add webhook receiver, consolidate shared utilities, expand telemetry coverage
- Add FastAPI webhook receiver (webhook_receiver_rev.py) for Jimi push data:
OBD diagnostics, DTC fault codes, alarms, GPS, heartbeats, trip reports
- Add schema migration (03_webhook_schema_migration.sql) for webhook tables:
fault_codes, heartbeats, expanded obd_readings/trips/position_history/alarms
- Consolidate duplicated _safe/_shutdown into shared safe_task/setup_shutdown
in ts_shared_rev.py (DRY refactor)
- Add auto-commit to get_conn() context manager (prevents forgotten commits)
- Fix poll_trips to capture runTimeSecond and maxSpeed from API
- Add poll_parking via jimi.open.platform.report.parking
- Remove broken poll_obd (OBD is push-only, no polling endpoint exists)
- Fix alarms schema: add lat/lng/acc_status columns + dedup constraint
- Fix obd_readings schema: add dedup constraint
- Fix trigger DO block: replace nonexistent has_column with information_schema
- Narrow api_post exception handling to RequestException/ValueError
- Add webhook_receiver service to docker-compose.yaml
- Add fastapi/uvicorn/python-multipart to pyproject.toml
- Add clean_ts timestamp validator to ts_shared_rev.py
- Add Tracksolid Pro API documentation (tracksolidApiDocumentation.md)
- Populate .gitignore with Python/OS/secrets patterns
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 13:28:45 +00:00
|
|
|
healthcheck:
|
2026-04-08 15:54:42 +00:00
|
|
|
test: ["CMD", "curl", "-f", "http://localhost:8888/health"]
|
Add webhook receiver, consolidate shared utilities, expand telemetry coverage
- Add FastAPI webhook receiver (webhook_receiver_rev.py) for Jimi push data:
OBD diagnostics, DTC fault codes, alarms, GPS, heartbeats, trip reports
- Add schema migration (03_webhook_schema_migration.sql) for webhook tables:
fault_codes, heartbeats, expanded obd_readings/trips/position_history/alarms
- Consolidate duplicated _safe/_shutdown into shared safe_task/setup_shutdown
in ts_shared_rev.py (DRY refactor)
- Add auto-commit to get_conn() context manager (prevents forgotten commits)
- Fix poll_trips to capture runTimeSecond and maxSpeed from API
- Add poll_parking via jimi.open.platform.report.parking
- Remove broken poll_obd (OBD is push-only, no polling endpoint exists)
- Fix alarms schema: add lat/lng/acc_status columns + dedup constraint
- Fix obd_readings schema: add dedup constraint
- Fix trigger DO block: replace nonexistent has_column with information_schema
- Narrow api_post exception handling to RequestException/ValueError
- Add webhook_receiver service to docker-compose.yaml
- Add fastapi/uvicorn/python-multipart to pyproject.toml
- Add clean_ts timestamp validator to ts_shared_rev.py
- Add Tracksolid Pro API documentation (tracksolidApiDocumentation.md)
- Populate .gitignore with Python/OS/secrets patterns
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 13:28:45 +00:00
|
|
|
interval: 30s
|
|
|
|
|
timeout: 5s
|
|
|
|
|
retries: 3
|
2026-04-07 18:34:40 +00:00
|
|
|
|
2026-06-01 01:23:37 +00:00
|
|
|
dashboard_api:
|
|
|
|
|
# Stable read-API for the Live Position + Fleet Trips map dashboards.
|
|
|
|
|
# Replaces the n8n webhooks (n8n was only a thin HTTP->SQL proxy).
|
|
|
|
|
# Calls reporting.fn_live_positions / fn_vehicle_track / fn_trips_for_map.
|
|
|
|
|
build:
|
|
|
|
|
context: .
|
|
|
|
|
dockerfile: Dockerfile
|
|
|
|
|
command: sh -c "uvicorn dashboard_api_rev:app --host 0.0.0.0 --port 8890 --workers 2"
|
|
|
|
|
restart: always
|
|
|
|
|
depends_on:
|
|
|
|
|
timescale_db:
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
env_file: .env
|
|
|
|
|
environment:
|
|
|
|
|
# Browser origins allowed to call this API (the dashboard domains).
|
|
|
|
|
- DASHBOARD_CORS_ORIGINS=${DASHBOARD_CORS_ORIGINS:-https://liveposition.rahamafresh.com,https://fleetintelligence.rahamafresh.com}
|
|
|
|
|
# No host port binding — set a domain (e.g. fleetapi.rahamafresh.com) in the
|
|
|
|
|
# Coolify UI pointing to this service on port 8890. The dashboards then point
|
|
|
|
|
# their N8N_BASE at that domain; paths (/webhook/...) are unchanged.
|
|
|
|
|
healthcheck:
|
|
|
|
|
test: ["CMD", "curl", "-f", "http://localhost:8890/health"]
|
|
|
|
|
interval: 30s
|
|
|
|
|
timeout: 5s
|
|
|
|
|
retries: 3
|
|
|
|
|
|
2026-06-10 18:41:05 +00:00
|
|
|
# grafana — REMOVED 2026-06-10. Fleet visualisation/KPIs are now served by the
|
|
|
|
|
# FleetOps SPA (own repo) via the dashboard_api read layer. Pipeline freshness
|
|
|
|
|
# (the one thing only Grafana surfaced) is replaced by reporting.v_ingest_health
|
|
|
|
|
# (migration 19) exposed on the read-API. The grafana_ro role + reporting.*
|
|
|
|
|
# grants are retained (harmless, reusable). Provisioning kept in ./grafana for
|
|
|
|
|
# reference. To restore, re-add this service block.
|
2026-04-07 18:34:40 +00:00
|
|
|
|
2026-06-10 18:41:05 +00:00
|
|
|
# pgbouncer — REMOVED 2026-06-10. It was deployed but dormant (zero clients
|
|
|
|
|
# pointed at :6432; every service connects directly to timescale_db:5432).
|
|
|
|
|
# In-process pooling (ts_shared_rev ThreadedConnectionPool) is more than
|
|
|
|
|
# sufficient at this scale, and transaction-mode pooling is unsafe for the
|
|
|
|
|
# advisory-lock'd v_trips refresher (FIX-D02). Migration 10 (pgbouncer role +
|
|
|
|
|
# user_lookup()) is left applied but inert. To restore, re-add this service block.
|
2026-05-07 10:21:35 +00:00
|
|
|
|
2026-04-21 09:53:23 +00:00
|
|
|
db_backup:
|
|
|
|
|
build:
|
|
|
|
|
context: ./backup
|
|
|
|
|
dockerfile: Dockerfile
|
|
|
|
|
restart: always
|
|
|
|
|
depends_on:
|
|
|
|
|
timescale_db:
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
env_file: .env
|
|
|
|
|
environment:
|
2026-04-24 08:00:02 +00:00
|
|
|
# pg_dump → rustfs. Credentials from .env (RUSTFS_*).
|
2026-04-24 08:30:20 +00:00
|
|
|
# BACKUP_TIMES: comma-separated HH:MM list in local TZ (default Africa/Nairobi).
|
|
|
|
|
- TZ=${TZ:-Africa/Nairobi}
|
|
|
|
|
- BACKUP_TIMES=${BACKUP_TIMES:-02:30,08:30,14:30,20:30}
|
2026-04-21 09:53:23 +00:00
|
|
|
- BACKUP_KEEP_DAYS=${BACKUP_KEEP_DAYS:-30}
|
|
|
|
|
- BACKUP_RUN_ON_START=${BACKUP_RUN_ON_START:-0}
|
|
|
|
|
- RUSTFS_ENDPOINT=${RUSTFS_ENDPOINT}
|
|
|
|
|
- RUSTFS_ACCESS_KEY=${RUSTFS_ACCESS_KEY}
|
|
|
|
|
- RUSTFS_SECRET_KEY=${RUSTFS_SECRET_KEY}
|
|
|
|
|
- RUSTFS_BUCKET=${RUSTFS_BUCKET:-fleet-db}
|
|
|
|
|
|
2026-04-07 18:34:40 +00:00
|
|
|
volumes:
|
|
|
|
|
timescale-data:
|
|
|
|
|
name: timescale-data
|
2026-06-10 18:41:05 +00:00
|
|
|
# grafana-data removed with the grafana service (2026-06-10).
|