# PostGIS spatial stack for the trip planner. # # docker compose up -d postgis # start the DB (schema.sql runs on first boot) # ./import.sh ../osm/nh.osm.pbf # import an OSM extract (one-shot osm2pgsql) # 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:/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: