canvas-website/open-mapping.docker-compose...

161 lines
5.7 KiB
YAML

# Open Mapping Backend Services
# Deploy to: /opt/apps/open-mapping/ on Netcup RS 8000
#
# Prerequisites:
# 1. Download OSM data: wget https://download.geofabrik.de/europe/germany-latest.osm.pbf
# 2. Pre-process OSRM: docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-extract -p /opt/car.lua /data/germany-latest.osm.pbf
# Then: osrm-partition, osrm-customize
# 3. Download vector tiles or generate with OpenMapTiles
version: '3.8'
services:
# =========================================================================
# OSRM - Open Source Routing Machine
# Primary routing engine for fast route calculations
# =========================================================================
osrm:
image: osrm/osrm-backend:v5.27.1
container_name: open-mapping-osrm
restart: unless-stopped
volumes:
- ./data/osrm:/data:ro
command: osrm-routed --algorithm mld /data/germany-latest.osrm --max-table-size 10000
ports:
- "5000:5000" # Internal only, accessed via Traefik
networks:
- traefik-public
- open-mapping-internal
labels:
- "traefik.enable=true"
- "traefik.http.routers.osrm.rule=Host(`routing.jeffemmett.com`) && PathPrefix(`/osrm`)"
- "traefik.http.routers.osrm.middlewares=osrm-stripprefix"
- "traefik.http.middlewares.osrm-stripprefix.stripprefix.prefixes=/osrm"
- "traefik.http.services.osrm.loadbalancer.server.port=5000"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
interval: 30s
timeout: 10s
retries: 3
# =========================================================================
# Valhalla - Extended Routing Engine
# For isochrones, transit, and advanced features
# =========================================================================
valhalla:
image: ghcr.io/gis-ops/docker-valhalla/valhalla:latest
container_name: open-mapping-valhalla
restart: unless-stopped
volumes:
- ./data/valhalla:/custom_files
environment:
- tile_urls=https://download.geofabrik.de/europe/germany-latest.osm.pbf
- use_tiles_ignore_pbf=True
- build_elevation=True
- build_admins=True
- build_time_zones=True
- force_rebuild=False
ports:
- "8002:8002"
networks:
- traefik-public
- open-mapping-internal
labels:
- "traefik.enable=true"
- "traefik.http.routers.valhalla.rule=Host(`routing.jeffemmett.com`) && PathPrefix(`/valhalla`)"
- "traefik.http.routers.valhalla.middlewares=valhalla-stripprefix"
- "traefik.http.middlewares.valhalla-stripprefix.stripprefix.prefixes=/valhalla"
- "traefik.http.services.valhalla.loadbalancer.server.port=8002"
deploy:
resources:
limits:
memory: 8G
# =========================================================================
# TileServer GL - Vector Tile Server
# Serves map tiles for MapLibre GL JS
# =========================================================================
tileserver:
image: maptiler/tileserver-gl:v4.6.5
container_name: open-mapping-tiles
restart: unless-stopped
volumes:
- ./data/tiles:/data:ro
ports:
- "8080:8080"
networks:
- traefik-public
labels:
- "traefik.enable=true"
- "traefik.http.routers.tiles.rule=Host(`tiles.jeffemmett.com`)"
- "traefik.http.services.tiles.loadbalancer.server.port=8080"
# CORS headers for cross-origin tile requests
- "traefik.http.middlewares.tiles-cors.headers.accesscontrolallowmethods=GET,OPTIONS"
- "traefik.http.middlewares.tiles-cors.headers.accesscontrolalloworiginlist=*"
- "traefik.http.middlewares.tiles-cors.headers.accesscontrolmaxage=100"
- "traefik.http.routers.tiles.middlewares=tiles-cors"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
# =========================================================================
# VROOM - Vehicle Routing Optimization
# Solves TSP and VRP for multi-stop route optimization
# =========================================================================
vroom:
image: vroomvrp/vroom-docker:v1.14.0
container_name: open-mapping-vroom
restart: unless-stopped
environment:
- VROOM_ROUTER=osrm
- OSRM_URL=http://osrm:5000
ports:
- "3000:3000"
networks:
- traefik-public
- open-mapping-internal
labels:
- "traefik.enable=true"
- "traefik.http.routers.vroom.rule=Host(`routing.jeffemmett.com`) && PathPrefix(`/optimize`)"
- "traefik.http.routers.vroom.middlewares=vroom-stripprefix"
- "traefik.http.middlewares.vroom-stripprefix.stripprefix.prefixes=/optimize"
- "traefik.http.services.vroom.loadbalancer.server.port=3000"
depends_on:
- osrm
# =========================================================================
# API Gateway (optional)
# Unified routing API that abstracts backend services
# =========================================================================
# api:
# build: ./api
# container_name: open-mapping-api
# restart: unless-stopped
# environment:
# - OSRM_URL=http://osrm:5000
# - VALHALLA_URL=http://valhalla:8002
# - VROOM_URL=http://vroom:3000
# ports:
# - "4000:4000"
# networks:
# - traefik-public
# - open-mapping-internal
# labels:
# - "traefik.enable=true"
# - "traefik.http.routers.mapping-api.rule=Host(`mapping.jeffemmett.com`)"
# - "traefik.http.services.mapping-api.loadbalancer.server.port=4000"
networks:
traefik-public:
external: true
open-mapping-internal:
driver: bridge
# Persistent storage for processed routing data
volumes:
osrm-data:
valhalla-data:
tiles-data: