Persist chat history to Postgres via durable JetStream consumer

DATABASE_URL required at startup; schema self-initializes.
Compose gains a postgres service for standalone dev.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-08 22:14:26 +02:00
parent 6b97ec3b0f
commit ec3771f2e7
10 changed files with 696 additions and 21 deletions
+24 -1
View File
@@ -8,10 +8,14 @@ services:
env_file: .env
environment:
NATS_URL: nats://nats:4222
DATABASE_URL: postgres://cnats:cnats@postgres:5432/cnats
ports:
- "3000:3000"
depends_on:
- nats
nats:
condition: service_started
postgres:
condition: service_healthy
nats:
image: nats:2.10-alpine
@@ -19,3 +23,22 @@ services:
ports:
- "4222:4222" # client connections
- "8222:8222" # monitoring UI (http://localhost:8222)
postgres:
image: postgres:17-alpine
environment:
POSTGRES_USER: cnats
POSTGRES_PASSWORD: cnats
POSTGRES_DB: cnats
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U cnats -d cnats"]
interval: 2s
timeout: 3s
retries: 15
volumes:
pgdata: