trips/spatial/docker-compose.yml
Greg Pomerantz 3da04c111e Move runtime artifacts out of the source tree to ~/trips
The dev directory now holds source code + compiled binaries only:
  ~/trips/osm/          OSM PBF extracts (was osm/, 1.4 GB)
  ~/trips/tilecache/    mock tile cache (was mock/.tilecache)
  ~/trips/store/mock/   per-trip uploads + chat logs (was mock/store, PII)
  ~/trips/logs/         server.log
  ~/trips/stale-osm-build/  stale source/tarball dup of ~/osm-build
                           (repo osm/build had no binaries; the live OSRM
                           toolchain + graphs already lived in ~/osm-build)

Code now points at the new locations, all overridable via env:
- mock/server.js: TRIPS_HOME (default ~/trips) for tile cache + store
- setup-osrm.sh / setup-osrm-colombia.sh: OSM_DIR (default ~/trips/osm)
- spatial/compose+import.sh: OSM_DIR (default ~/trips/osm)
- .gitignore: rewritten — no artifact paths remain in-tree
2026-09-10 10:03:04 -04:00

64 lines
2.1 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 # import ~/trips/osm/nh.osm.pbf (one-shot osm2pgsql)
#
# OSM_DIR (default ~/trips/osm) is where the PBF extracts live — outside the
# dev tree. Export it to override.
# docker compose run --rm spatiald # start the query service on :5005
#
# The PBF extracts live in ../osm (gitignored). osm2pgsql runs as a one-shot
# container so the host needs no osm2pgsql/osmium installation.
services:
postgis:
image: postgis/postgis:16-3.4
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
healthcheck:
test: ["CMD-SHELL", "pg_isready -U trips -d trips"]
interval: 5s
timeout: 3s
retries: 12
# One-shot importer. `docker compose run --rm importer` (or import.sh)
# loads the PBF named in PBF_FILE into the DB. The osm2pgsql image runs
# as uid 1001 and needs the PBF readable — import.sh bind-mounts ../osm.
importer:
image: osm2pgsql/osm2pgsql:16
user: "1001:1001"
network_mode: "service:postgis"
environment:
PBF_FILE: /data/nh.osm.pbf
# --create --clean: fresh load every time (extracts are small enough);
# slim mode keeps the RAM footprint sane; disable-operations saves time.
ARGS: >-
--host=postgis --port=5432 --database=trips --user=trips
--password=trips --create --clean --slim
--flat-nodes=/tmp/flat.nodes --disable-operations
--import-strips=10
volumes:
- ${OSM_DIR:-$HOME/trips/osm}:/data:ro
spatiald:
build: .
container_name: trips-spatiald
environment:
SPATIAL_DSN: "host=postgis port=5432 user=trips password=trips dbname=trips sslmode=disable"
ports:
- "5005:5005"
depends_on:
postgis:
condition: service_healthy
volumes:
pgdata: