126 lines
5.0 KiB
YAML
126 lines
5.0 KiB
YAML
# TRM platform — deployment stack
|
||
#
|
||
# Deployed via Portainer Repository Stack:
|
||
# Repository: git.dev.microservices.al/trm/deploy
|
||
# Compose path: compose.yaml
|
||
# Branch: main
|
||
#
|
||
# Images are built and pushed by each service's own Gitea workflow.
|
||
# This file references them by tag and runs them as a coordinated stack.
|
||
#
|
||
# Before first deploy on the host: `docker login git.dev.microservices.al`
|
||
# (Portainer can store registry credentials in its UI; configure once.)
|
||
#
|
||
# Environment variables are populated from Portainer's stack environment
|
||
# config (or a `.env` file alongside this compose for non-Portainer hosts).
|
||
# Defaults are provided via `${VAR:-default}` so the stack starts with no
|
||
# explicit configuration on a fresh deploy.
|
||
|
||
name: trm
|
||
|
||
services:
|
||
# -------------------------------------------------------------------
|
||
# Redis — telemetry queue + (future) connection registry for Phase 2.
|
||
# Internal-only; no host port mapping.
|
||
# -------------------------------------------------------------------
|
||
redis:
|
||
image: redis:7-alpine
|
||
expose:
|
||
- '6379'
|
||
volumes:
|
||
- redis-data:/data
|
||
restart: unless-stopped
|
||
healthcheck:
|
||
test: ['CMD', 'redis-cli', 'ping']
|
||
interval: 10s
|
||
timeout: 3s
|
||
retries: 5
|
||
|
||
# -------------------------------------------------------------------
|
||
# tcp-ingestion — Teltonika telemetry TCP server.
|
||
# Built by git.dev.microservices.al/trm/tcp-ingestion's Gitea workflow.
|
||
# -------------------------------------------------------------------
|
||
tcp-ingestion:
|
||
image: git.dev.microservices.al/trm/tcp-ingestion:${TCP_INGESTION_TAG:-main}
|
||
depends_on:
|
||
redis:
|
||
condition: service_healthy
|
||
ports:
|
||
# Devices connect to this port. Use `${HOST_BIND_IP:-0.0.0.0}:5027:5027`
|
||
# if you want to restrict which host interface accepts connections.
|
||
- '${TCP_INGESTION_PORT:-5027}:5027'
|
||
environment:
|
||
NODE_ENV: production
|
||
INSTANCE_ID: ${TCP_INGESTION_INSTANCE_ID:-stage-1}
|
||
REDIS_URL: redis://redis:6379
|
||
# Pinned explicitly here to keep tcp-ingestion and processor in sync;
|
||
# neither service's compiled default is authoritative — the deploy
|
||
# stack is the single source of truth for the stream name.
|
||
REDIS_TELEMETRY_STREAM: ${REDIS_TELEMETRY_STREAM:-telemetry:teltonika}
|
||
LOG_LEVEL: ${LOG_LEVEL:-info}
|
||
restart: unless-stopped
|
||
|
||
# -------------------------------------------------------------------
|
||
# postgres — PostgreSQL 16 with TimescaleDB + PostGIS extensions
|
||
# (and others) bundled. Image: timescale/timescaledb-ha, `-all` suffix
|
||
# = all extensions present and ready for `CREATE EXTENSION`.
|
||
#
|
||
# Schema is owned by Directus (when it lands); the `positions`
|
||
# hypertable is owned by the processor's migration runner.
|
||
# Internal-only; no host port mapping.
|
||
#
|
||
# The image tag should be reviewed every 3–6 months. Pick the latest
|
||
# stable `pg16-ts*-all` build from Docker Hub:
|
||
# https://hub.docker.com/r/timescale/timescaledb-ha/tags
|
||
# Pin to a specific tag (not rolling `pg16`) so deploys are reproducible.
|
||
# -------------------------------------------------------------------
|
||
postgres:
|
||
image: timescale/timescaledb-ha:pg16.6-ts2.17.2-all
|
||
expose:
|
||
- '5432'
|
||
volumes:
|
||
- postgres-data:/home/postgres/pgdata/data
|
||
environment:
|
||
POSTGRES_USER: ${POSTGRES_USER:-trm}
|
||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-trm-pilot-change-me}
|
||
POSTGRES_DB: ${POSTGRES_DB:-trm}
|
||
restart: unless-stopped
|
||
healthcheck:
|
||
test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER:-trm} -d ${POSTGRES_DB:-trm}']
|
||
interval: 10s
|
||
timeout: 3s
|
||
retries: 5
|
||
|
||
# -------------------------------------------------------------------
|
||
# processor — consumes telemetry from Redis, writes to Postgres.
|
||
# Built by git.dev.microservices.al/trm/processor's Gitea workflow.
|
||
# -------------------------------------------------------------------
|
||
processor:
|
||
image: git.dev.microservices.al/trm/processor:${PROCESSOR_TAG:-main}
|
||
depends_on:
|
||
redis:
|
||
condition: service_healthy
|
||
postgres:
|
||
condition: service_healthy
|
||
environment:
|
||
NODE_ENV: production
|
||
INSTANCE_ID: ${PROCESSOR_INSTANCE_ID:-processor-1}
|
||
REDIS_URL: redis://redis:6379
|
||
# Must match tcp-ingestion's REDIS_TELEMETRY_STREAM — both pinned
|
||
# to the same shared variable so they cannot drift.
|
||
REDIS_TELEMETRY_STREAM: ${REDIS_TELEMETRY_STREAM:-telemetry:teltonika}
|
||
POSTGRES_URL: postgres://${POSTGRES_USER:-trm}:${POSTGRES_PASSWORD:-trm-pilot-change-me}@postgres:5432/${POSTGRES_DB:-trm}
|
||
LOG_LEVEL: ${LOG_LEVEL:-info}
|
||
restart: unless-stopped
|
||
|
||
# -------------------------------------------------------------------
|
||
# Future services land here:
|
||
# - directus: business-plane API + admin UI
|
||
# - react-spa: front-end (static, served via nginx or Caddy)
|
||
# See ../docs/wiki/ for the platform architecture.
|
||
# -------------------------------------------------------------------
|
||
|
||
volumes:
|
||
redis-data:
|
||
postgres-data:
|