├── data └── .gitkeep ├── .gitignore ├── .dockerignore ├── generate_tiles.sh ├── scripts └── gen_tiles.sh ├── start_server.sh ├── README.md └── Dockerfile /data/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | data/* 2 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | data/* 2 | -------------------------------------------------------------------------------- /generate_tiles.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | docker run -it --rm -v $(pwd)/data:/data/valhalla valhalla /bin/bash /opt/scripts/gen_tiles.sh 3 | -------------------------------------------------------------------------------- /scripts/gen_tiles.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | LD_LIBRARY_PATH=/usr/lib:/usr/local/lib /opt/mjolnir/pbfgraphbuilder -c /data/valhalla/valhalla.json /data/valhalla/*.pbf 3 | -------------------------------------------------------------------------------- /start_server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "Starting valhalla at http://$(docker-machine ip default):5432" 3 | docker run --rm -p 5432:8002/tcp -it -v $(pwd)/data:/data/valhalla valhalla 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Valhalla docker 2 | 3 | This is a dockerised version of [Valhalla](https://github.com/valhalla), the routing engine from [Map Zen](https://mapzen.com/) 4 | 5 | # Building the image 6 | 7 | docker build -t valhalla . 8 | 9 | # Generating the tiles 10 | 11 | Before Valhalla can run we need to generate the tiles it will use for routing. 12 | Create a data directory at the root of this repo 13 | 14 | mkdir data 15 | 16 | Then download the opensteetmap files for the regions you are interested in. For 17 | example if you want to have routing in New York grab the corresponding osm.pbf file from 18 | [http://download.geofabrik.de](http://download.geofabrik.de) 19 | 20 | cd data 21 | wget http://download.geofabrik.de/north-america/us/new-york-latest.osm.pbf 22 | 23 | 24 | Also we need to fetch a configuration file for valhalla. You can grab the one [here](https://github.com/valhalla/conf/blob/master/valhalla.json) and place it in 25 | the data folder as well. 26 | 27 | Finally run the generate_tiles.sh script 28 | 29 | ./generate_tiles.sh 30 | 31 | which will generate the tiles in the data directory. 32 | 33 | # Starting the server 34 | 35 | Finally to start the server run 36 | 37 | ./start_server.sh 38 | 39 | which will start the server running on port 5432 (you can change this by editing start_server.sh). 40 | 41 | Alternatively run the docker command 42 | 43 | docker run --rm -p 5432:8002/tcp -it -v $(pwd)/data:/data/valhalla valhalla 44 | 45 | 46 | # Getting routes 47 | 48 | If you are using docker machine you can grab the ip of the instance by running 49 | 50 | docker-machine ip default 51 | 52 | then simply point your browser or curl or whatever at that ip and port 5432. 53 | For example 54 | 55 | curl http://192.168.99.100:5432/route?json={%22locations%22:[{%22lat%22:40.70236,%22lon%22:-73.91661},{%22lat%22:40.70451,%22lon%22:-73.93667}],%22costing%22:%22auto%22} 56 | 57 | 58 | # Pull requests 59 | 60 | Relatively new to Docker, if you have updates or improvements to this repo 61 | pull requests are very welcome 62 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | from ubuntu 2 | 3 | EXPOSE 8080 4 | #add ppa for newer compiler 5 | RUN apt-get update; apt-get install -y software-properties-common python-software-properties; add-apt-repository -y ppa:ubuntu-toolchain-r/test; apt-get update -o Dir::Etc::sourcelist="sources.list.d/ubuntu-toolchain-r-test-$(lsb_release -c -s).list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" 6 | 7 | #grab all of the dependencies 8 | RUN apt-get install -y autoconf automake libtool make gcc-4.9 g++-4.9 libboost1.54-dev libboost-program-options1.54-dev libboost-filesystem1.54-dev libboost-system1.54-dev libboost-thread1.54-dev protobuf-compiler libprotobuf-dev lua5.2 liblua5.2-dev git firefox libsqlite3-dev libspatialite-dev libgeos-dev libgeos++-dev libcurl4-openssl-dev git wget 9 | 10 | #use newer compiler 11 | RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 90; update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 90 12 | 13 | 14 | WORKDIR /opt 15 | 16 | RUN git clone --depth=1 --recurse-submodules --single-branch --branch=master https://github.com/zeromq/libzmq.git 17 | WORKDIR /opt/libzmq 18 | RUN ./autogen.sh 19 | RUN ./configure --without-libsodium --without-documentation; make install 20 | WORKDIR /opt 21 | 22 | #grab prime_server API: 23 | RUN git clone --depth=1 --recurse-submodules --single-branch --branch=master https://github.com/kevinkreiser/prime_server.git 24 | WORKDIR /opt/prime_server 25 | RUN ./autogen.sh; ./configure ; make install 26 | WORKDIR /opt 27 | 28 | #grab midgard 29 | RUN git clone --recurse-submodules https://github.com/valhalla/midgard 30 | WORKDIR /opt/midgard 31 | RUN ./autogen.sh; ./configure CPPFLAGS=-DBOOST_SPIRIT_THREADSAFE; make ; make install; 32 | WORKDIR /opt 33 | 34 | #grab baldr 35 | RUN git clone --recurse-submodules https://github.com/valhalla/baldr 36 | WORKDIR /opt/baldr 37 | RUN ./autogen.sh; ./configure CPPFLAGS=-DBOOST_SPIRIT_THREADSAFE; make ; make install; 38 | WORKDIR /opt 39 | 40 | #grab sif 41 | RUN git clone --recurse-submodules https://github.com/valhalla/sif 42 | WORKDIR /opt/sif 43 | RUN ./autogen.sh; ./configure CPPFLAGS=-DBOOST_SPIRIT_THREADSAFE; make ; make install; 44 | WORKDIR /opt 45 | 46 | #grab skadi 47 | RUN git clone --recurse-submodules https://github.com/valhalla/skadi 48 | WORKDIR /opt/skadi 49 | RUN ./autogen.sh; ./configure CPPFLAGS=-DBOOST_SPIRIT_THREADSAFE; make ; make install; 50 | WORKDIR /opt 51 | 52 | #grab mjolnir 53 | RUN git clone --recurse-submodules https://github.com/valhalla/mjolnir 54 | WORKDIR /opt/mjolnir 55 | RUN ./autogen.sh; ./configure CPPFLAGS=-DBOOST_SPIRIT_THREADSAFE; make ; make install; 56 | WORKDIR /opt 57 | 58 | #grab loki 59 | RUN git clone --recurse-submodules https://github.com/valhalla/loki 60 | WORKDIR /opt/loki 61 | RUN ./autogen.sh; ./configure CPPFLAGS=-DBOOST_SPIRIT_THREADSAFE; make ; make install; 62 | WORKDIR /opt 63 | 64 | 65 | #grab yaml-cpp 66 | RUN git clone https://github.com/jbeder/yaml-cpp.git 67 | RUN mkdir yaml-cpp/build 68 | 69 | RUN apt-get install -y cmake 70 | WORKDIR /opt/yaml-cpp/build 71 | RUN cmake ../ ; make; make install 72 | WORKDIR /opt 73 | 74 | #grab odin 75 | 76 | RUN git clone https://github.com/valhalla/odin.git 77 | WORKDIR /opt/odin 78 | RUN scripts/dependencies.sh ; ./scripts/install.sh 79 | WORKDIR /opt 80 | 81 | #grab thor 82 | RUN git clone --recurse-submodules https://github.com/valhalla/thor.git 83 | WORKDIR /opt/thor 84 | RUN ./autogen.sh; ./configure CPPFLAGS=-DBOOST_SPIRIT_THREADSAFE; make ; make install; 85 | WORKDIR /opt 86 | 87 | #grab tyr 88 | RUN git clone --recurse-submodules https://github.com/valhalla/tyr.git 89 | WORKDIR /opt/tyr 90 | RUN ./autogen.sh; ./configure CPPFLAGS=-DBOOST_SPIRIT_THREADSAFE; make ; make install; 91 | WORKDIR /opt 92 | 93 | #grab tools 94 | 95 | RUN git clone --recurse-submodules https://github.com/valhalla/tools.git 96 | WORKDIR /opt/tools 97 | RUN ./autogen.sh; ./configure CPPFLAGS=-DBOOST_SPIRIT_THREADSAFE; make ; make install; 98 | WORKDIR /opt 99 | 100 | ADD scripts /opt/scripts 101 | #Run the server 102 | CMD chmod 777 /opt/scripts/* 103 | WORKDIR /opt/tyr 104 | 105 | EXPOSE 8002 106 | EXPOSE 8080 107 | 108 | CMD LD_LIBRARY_PATH=/usr/lib:/usr/local/lib /opt/tools/tyr_simple_service /data/valhalla/valhalla.json 109 | #CMD LD_LIBRARY_PATH=/usr/lib:/usr/local/lib tyr/tyr_simple_service tyr/conf/valhalla.json 110 | 111 | 112 | 113 | 114 | 115 | # 116 | # 117 | # 118 | --------------------------------------------------------------------------------