I came across this post since I was having an issue to make this example, work on a local setup. Since ORS doesn’t have the optimization code embedded in it anymore, you must use vroom+ors for optimization.
here’s a docker-compose.yml with this setup:
version: '2.4'
services:
ors:
container_name: ors
image: openrouteservice/openrouteservice:latest
ports:
- 8080:8080
- 9001:9001
user: "${ORS_UID:-0}:${ORS_GID:-0}"
volumes:
- ./graphs:/ors-core/data/graphs
- ./elevation_cache:/ors-core/data/elevation_cache
- ./logs/ors:/var/log/ors
- ./logs/tomcat:/usr/local/tomcat/logs
- ./conf:/ors-conf
# - ./new-york-latest.osm.pbf:/ors-core/data/osm_file.pbf
environment:
- BUILD_GRAPHS=True # Forces the container to rebuild the graphs, e.g. when PBF is changed
- "JAVA_OPTS=-Djava.awt.headless=true -server -XX:TargetSurvivorRatio=75 -XX:SurvivorRatio=64 -XX:MaxTenuringThreshold=3 -XX:+UseG1GC -XX:+ScavengeBeforeFullGC -XX:ParallelGCThreads=4 -Xms1g -Xmx2g"
- "CATALINA_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9001 -Dcom.sun.management.jmxremote.rmi.port=9001 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost"
vroom:
container_name: vroom2
image: vroomvrp/vroom-docker:v1.12.0
network_mode: host
volumes:
- ./vroom-conf/:/conf
environment:
- VROOM_ROUTER=ors # router to use, osrm, valhalla or ors
depends_on:
- ors
create the folders that the yaml is expecting: mkdir -p vroom-conf conf elevation_cache graphs logs/ors logs/tomcat
start this with docker compose up --build
To test that ORS is running go to: localhost:8080/ors/health
it should return {"status":"ready"}
Then test to make sure ORS has loaded your maps (especially if you are putting your own custom ones) and you are testing coordinates that fall in the loaded maps. If you are using the default ORS docker:
Execute this to see: localhost:8080/ors/v2/directions/driving-car?start=8.681495,49.41461&end=8.687872,49.420318
Now that you’ve confirmed that ORS is working, you need to update the vroom config.
Take down docker (with ctrl+c)
in vroom-conf/config.yml, you’ll need to change the router and baseurl:
router: 'ors' # routing backend (osrm, libosrm or ors)
baseurl: '/optimization/' #base url for api
You may need to make the file writeable with: chmod a+w config.yml
Now restart with docker compose up --build
Test to make sure vroom is up:
curl -w "%{http_code}\n" http://localhost:3000/health
Now make a call to the optimization endpoint by calling vroom, not ORS.
localhost:3000/optimization with your corresponding json (I would recommend using postman to send the request)
vroom will then call ORS to get information and return a response.