trips/spatial/docker-compose.yml
Greg Pomerantz 7efd2567b2 spatial: pgvector semantic POI index + UI map pins
- db/Dockerfile: postgis:16-3.4 + postgresql-16-pgvector (works around the
  EOL bullseye release files: disable Check-Valid-Until, add pgdg repo)
- 20-vector.sql: CREATE EXTENSION vector on first boot
- embed/main.go (embedpoi): build poi_vec from poi — zembed embeddings of
  'name — kind' (2560-d), resumable, HNSW cosine index at the end
- main.go: /semantic endpoint (embeds q with the local model, cosine <=>
  over poi_vec, returns lat/lng/score); add lat/lng to /near /nearest
  /corridor so the UI can pin results; bind the vector as a text literal
  + ::vector cast (lib/pq has no []float32 codec)
- mock/app.js: poi_semantic tool + poi_near now returns coords; agent loop
  drops poi_near/poi_semantic results as map pins (showSpatialPins)
- mock/styles.css: .sp-dot / .sp-card pin + popup styles
- README: document the pgvector stack + embedpoi
2026-09-10 14:08:53 -04:00

63 lines
2.3 KiB
YAML

# PostGIS spatial stack for the trip planner.
#
# docker-compose up -d postgis # start the DB (schema.sql runs on first boot)
# ./import.sh ~/trips/osm/nh.osm.pbf nh # import an OSM extract (one-shot osm2pgsql)
# docker-compose up -d spatiald # start the query service on :5005
#
# Composed for docker-compose v1 (3.8) AND v2 (the same file works with
# `docker compose` once the v2 plugin is available): no healthchecks or
# `depends_on` conditions — import.sh polls pg_isready itself, and spatiald
# tolerates a not-yet-ready DB at boot.
#
# OSM_DIR (default ~/trips/osm) is where the PBF extracts live — outside the
# dev tree. Export it to override.
version: "3.8"
services:
postgis:
build: ./db # postgis/postgis:16-3.4 + postgresql-16-pgvector (db/Dockerfile)
container_name: trips-postgis
environment:
POSTGRES_DB: trips
POSTGRES_USER: trips
POSTGRES_PASSWORD: trips
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
# initdb scripts run in lexicographic order, once, on an empty volume
- ./schema.sql:/docker-entrypoint-initdb.d/10-schema.sql:ro
- ./20-vector.sql:/docker-entrypoint-initdb.d/20-vector.sql:ro
restart: unless-stopped
# One-shot importer (also usable as: docker-compose run --rm importer
# -- /data/<file>.osm.pbf ...). import.sh does the same with a bare
# `docker run`, since the PBF path varies per import.
importer:
image: iboates/osm2pgsql:latest
entrypoint: osm2pgsql
environment:
PGPASSWORD: trips # the image build's --password flag forces a prompt
command: >-
/data/colombia.osm.pbf --host=postgis --port=5432 --database=trips
--user=trips -k --slim
--flat-nodes=/tmp/flat.nodes
network_mode: "service:postgis"
volumes:
- ${OSM_DIR}:/data:ro # OSM_DIR is exported by import.sh (default ~/trips/osm)
spatiald:
build: .
container_name: trips-spatiald
environment:
SPATIAL_DSN: "host=postgis port=5432 user=trips password=trips dbname=trips sslmode=disable"
EMBED_BASE: ${EMBED_BASE:-http://192.168.3.7:1234/v1}
EMBED_MODEL: ${EMBED_MODEL:-zembed-1-Q4_K_M}
ports:
- "5005:5005"
depends_on:
- postgis
restart: unless-stopped
volumes:
pgdata: