The repository-root docker-compose.yml brings up every service PrediFi needs
for local development: PostgreSQL, Redis, a local Stellar network, the Axum
backend and the Next.js dev server. An optional profile adds a Loki-based log
aggregation stack.
- Docker Engine 24+ with the Compose v2 plugin (
docker compose version) - Roughly 8 GB of free disk space — the Stellar quickstart image and the Rust build cache are the bulk of it
docker compose up| Service | URL | Notes |
|---|---|---|
frontend |
http://localhost:3001 | Next.js dev server with hot reload |
backend |
http://localhost:3000 | Axum API; /health for readiness |
postgres |
localhost:5432 |
user/password/database: postgres/postgres/predifi |
redis |
localhost:6379 |
|
stellar |
http://localhost:8000 | Local network; Soroban RPC at /rpc |
The first docker compose up is slow: the Rust dependency tree is compiled
from scratch and the Stellar quickstart image initialises its ledger. Both are
cached in named volumes, so subsequent starts are fast.
Both application services bind-mount their source directory:
backendruns undercargo watchand rebuilds whenbackend/srcorbackend/Cargo.tomlchanges. On macOS and Windows, bind mounts do not propagate inotify events reliably — append--pollto thecargo watchcommand inbackend/Dockerfile.devif rebuilds do not trigger.frontendrunsnext devwithWATCHPACK_POLLING=truealready set.
node_modules, .next and target live in named volumes so host artifacts
never shadow the container's.
The db-seed service runs the sqlx migrations and inserts deterministic sample
data before the backend starts. It is idempotent (every insert uses
ON CONFLICT), so it re-runs safely on every up.
To wipe and re-seed:
docker compose run --rm db-seed cargo run --bin predifi-seed -- --freshdocker compose down -v # removes containers and all named volumesThe logging profile adds Loki (storage and query), Promtail (shipping) and
Grafana (dashboards and alerts):
docker compose --profile logging upGrafana is at http://localhost:3002 (admin / admin) with the Loki data
source pre-provisioned and the PrediFi — Logs & Error Trends dashboard in
the PrediFi folder.
- The backend logs structured JSON through
tracing-subscriber. - Promtail discovers every container in this compose project through the Docker daemon and ships their stdout/stderr to Loki.
- Backend lines are parsed as JSON, so
levelandspan_namebecome Loki labels and the rendered line is just the message. Other services are shipped verbatim.
Useful LogQL queries:
{job="predifi", service="backend", level="ERROR"}
sum by (service) (rate({job="predifi", level="ERROR"}[5m]))
{job="predifi"} |= "pool_id"
docker/loki/rules/fake/predifi-log-alerts.yml defines log-based alerts —
error-rate spikes, Rust panics, repeated database errors, and a dead-man's
switch for missing backend logs. The Loki ruler evaluates them and Grafana
surfaces them under Alerting → Alert rules (the data source is provisioned
with manageAlerts: true).
The fake directory name is Loki's tenant ID when auth_enabled is false; it
is not a placeholder.
No Alertmanager is included, so alerts are visible but not routed. Point the
ruler at one by adding alertmanager_url to docker/loki/loki-config.yml.
All long-running services declare Docker health checks. Dependent services use
condition: service_healthy so a cold docker compose up reaches a working
stack without manual restarts:
- PostgreSQL —
pg_isready - Redis —
redis-cli ping - Stellar — HTTP probe on port
8000 - Backend — HTTP probe on
/health - Loki — HTTP probe on
/ready - Promtail — waits for Loki, then HTTP probe on
/ready - Grafana — waits for Loki, then HTTP probe on
/api/health
The db-seed service waits for PostgreSQL to report healthy before running
migrations.
| Path | Purpose |
|---|---|
docker-compose.yml |
Service definitions |
backend/Dockerfile.dev, frontend/Dockerfile.dev |
Development images |
docker/loki/loki-config.yml |
Loki single-binary configuration |
docker/loki/rules/fake/predifi-log-alerts.yml |
Log-based alert rules |
docker/promtail/promtail-config.yml |
Log shipping and JSON parsing |
docker/grafana/provisioning/ |
Data source and dashboard wiring |
docker/grafana/dashboards/predifi-logs.json |
Error trend dashboard |