Skip to content

Instantly share code, notes, and snippets.

@zubair1024
Last active December 21, 2019 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zubair1024/e35809e3c8a976698114cd20b4359f7e to your computer and use it in GitHub Desktop.
Save zubair1024/e35809e3c8a976698114cd20b4359f7e to your computer and use it in GitHub Desktop.

Setting up OSRM backend using Docker

  • Download map layer from source

wget https://download.geofabrik.de/asia/gcc-states-latest.osm.pbf

  • Pre-process the extract with the car profile and start a routing engine HTTP server on port 5000

docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-extract -p /opt/car.lua /data/gcc-states-latest.osm.pbf

Note: The flag -v "${PWD}:/data" creates the directory /data inside the docker container and makes the current working directory "${PWD}" available there. The file /data/*.osm.pbf inside the container is referring to "${PWD}/*.osm.pbf" on the host.

  • Run the osrm-partition logic

docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-partition /data/gcc-states-latest.osrm

  • Run the osrm-customize logic

docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-customize /data/gcc-states-latest.osrm

  • Now run the server

docker run -t -i -p 5000:5000 -v "${PWD}:/data" osrm/osrm-backend osrm-routed --algorithm mld /data/gcc-states-latest.osrm

Voila! You're done. Now you can test out the server running on port 5000

curl "http://127.0.0.1:5000/route/v1/driving/13.388860,52.517037;13.385983,52.496891?steps=true"

Sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment