- Add app/db/ abstraction layer: Backend enum, DbConn wrapper, dialect helper (q() for ? vs %s paramstyle), get_conn(), tenant_id() - Auto-detect backend from DATABASE_URL; SQLite remains default when unset — no config change for local deployments - Add tenant_id column to all three logical DBs (main, context, incidents); idempotent ALTER TABLE migration runs before schema scripts on existing DBs - All INSERTs inject tenant_id; SELECTs use (tenant_id = ? OR tenant_id = '') for backward compat with pre-namespacing rows - Add docker-compose.yml with named volume turnstone_pgdata (survives rebuilds) and optional external Postgres support via DATABASE_URL override - Add scripts/migrate_sqlite_to_postgres.py — one-shot idempotent migration for existing SQLite data; ON CONFLICT DO NOTHING for safe re-runs - Fix SSH glean path in pipeline.py to use ensure_schema + get_conn (was still using raw sqlite3.connect + old _SCHEMA without tenant_id) - Fix FTS5 JOIN ambiguity: qualify repeat_count as f.repeat_count in search - Update all tests to use ensure_*_schema fixtures; add row_factory where needed - 394/394 tests passing Closes: #42 Closes: #50
50 lines
1.6 KiB
YAML
50 lines
1.6 KiB
YAML
version: "3.9"
|
|
|
|
# Turnstone with external Postgres DB.
|
|
# Data lives in the named volume `turnstone_pgdata` — survives image rebuilds.
|
|
# To adopt an EXISTING Postgres install, set DATABASE_URL to point at it and
|
|
# remove the `db` service and `depends_on` blocks.
|
|
#
|
|
# Quick start:
|
|
# docker compose up -d
|
|
# # Then open http://localhost:8520
|
|
|
|
services:
|
|
db:
|
|
image: postgres:16-alpine
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_DB: turnstone
|
|
POSTGRES_USER: turnstone
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-turnstone_dev}
|
|
volumes:
|
|
- turnstone_pgdata:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U turnstone -d turnstone"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
turnstone:
|
|
build: .
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${TURNSTONE_PORT:-8520}:8520"
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
environment:
|
|
# Backend selection — comment out DATABASE_URL to fall back to SQLite
|
|
DATABASE_URL: postgresql://turnstone:${POSTGRES_PASSWORD:-turnstone_dev}@db:5432/turnstone
|
|
TURNSTONE_TENANT_ID: ${TURNSTONE_TENANT_ID:-}
|
|
TURNSTONE_API_KEY: ${TURNSTONE_API_KEY:-}
|
|
TURNSTONE_GLEAN_INTERVAL: ${TURNSTONE_GLEAN_INTERVAL:-900}
|
|
TURNSTONE_SOURCE_HOST: ${TURNSTONE_SOURCE_HOST:-}
|
|
TURNSTONE_SUBMIT_ENDPOINT: ${TURNSTONE_SUBMIT_ENDPOINT:-}
|
|
volumes:
|
|
- ./patterns:/app/patterns:ro
|
|
- ./data:/app/data # optional: persists SQLite files if DATABASE_URL unset
|
|
|
|
volumes:
|
|
turnstone_pgdata:
|
|
name: turnstone_pgdata
|