├── Dockerfile ├── LICENSE ├── README.md └── docker-entrypoint.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:trusty 2 | MAINTAINER Alex Newman 3 | 4 | # Let the container know that there is no TTY 5 | ENV DEBIAN_FRONTEND noninteractive 6 | 7 | # Install necessary packages for proper system state 8 | RUN apt-get -y update && apt-get install -y \ 9 | build-essential \ 10 | cmake \ 11 | curl \ 12 | git \ 13 | libboost-all-dev \ 14 | libbz2-dev \ 15 | libstxxl-dev \ 16 | libstxxl-doc \ 17 | libstxxl1 \ 18 | libtbb-dev \ 19 | libxml2-dev \ 20 | libzip-dev \ 21 | lua5.1 \ 22 | liblua5.1-0-dev \ 23 | libluabind-dev \ 24 | libluajit-5.1-dev \ 25 | pkg-config 26 | 27 | RUN mkdir -p /osrm-build \ 28 | && mkdir -p /osrm-data 29 | 30 | WORKDIR /osrm-build 31 | 32 | RUN curl --silent -L https://github.com/Project-OSRM/osrm-backend/archive/v5.2.6.tar.gz -o v5.2.6.tar.gz \ 33 | && tar xzf v5.2.6.tar.gz \ 34 | && mv osrm-backend-5.2.6 /osrm-src \ 35 | && cmake /osrm-src \ 36 | && make \ 37 | && mv /osrm-src/profiles/car.lua profile.lua \ 38 | && mv /osrm-src/profiles/lib/ lib \ 39 | && echo "disk=/tmp/stxxl,25000,syscall" > .stxxl \ 40 | && rm -rf /osrm-src 41 | 42 | # Cleanup -------------------------------- 43 | 44 | RUN apt-get clean \ 45 | && rm -rf /var/lib/apt/lists/* 46 | 47 | # Publish -------------------------------- 48 | 49 | COPY docker-entrypoint.sh / 50 | RUN chmod +x /docker-entrypoint.sh 51 | ENTRYPOINT ["/docker-entrypoint.sh"] 52 | 53 | EXPOSE 5000 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Open Source Cartography 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dockerfile for osrm-backend 2 | This container run [osrm-backend](https://github.com/Project-OSRM/osrm-backend) project. 3 | Open Source Routing Machine (OSRM) Docker Image [\[Docker Hub\]](https://hub.docker.com/r/cartography/osrm-backend-docker/) 4 | 5 | ## Installation 6 | 7 | 1. Install [Docker](https://www.docker.com/) 8 | 9 | 2. Manual deploy (optional). 10 | 11 | Pull automated build from Docker Hub: 12 | ``` 13 | $ docker pull cartography/osrm-backend-docker 14 | ``` 15 | or build from GitHub: 16 | ``` 17 | $ docker build -t="cartography/osrm-backend-docker" github.com/cartography/osrm-backend-docker 18 | ``` 19 | or you can clone & build: 20 | ``` 21 | $ git clone https://github.com/cartography/osrm-backend-docker.git 22 | $ docker build -t="cartography/osrm-backend-docker" osrm-backend-docker/ 23 | ``` 24 | 25 | ## Usage 26 | Run it: 27 | ``` 28 | docker run -d -p 5000:5000 cartography/osrm-backend-docker:latest osrm label "http://your/path/to/data.osm.pbf" 29 | ``` 30 | 31 | Explanation: 32 | - `-d` - run container in background and print container ID 33 | - `-p 5000:5000` - publish a container port to host 34 | - `osrm` - go via entrypoint script, w/o osrm keyword - classic mode 35 | - `label` - your label of OSM data 36 | - `url` - link to OSM data in PBF format 37 | 38 | For example: 39 | ``` 40 | docker run -d -p 5000:5000 --name osrm-api cartography/osrm-backend-docker:latest osrm California "http://download.geofabrik.de/north-america/us/california-latest.osm.pbf" 41 | ``` 42 | 43 | ## Start OSRM Frontend 44 | 45 | docker run -d --link osrm-api:api --name osrm-mos-front --restart=always -p 8080:80 cartography/osrm-frontend-docker 46 | 47 | You must `--link` osrm-frontend container with osrm-api with `api` tag. Or use `API_PORT_5000_TCP_ADDR` and `API_PORT_5000_TCP_PORT` variables to set host and port of the api. 48 | 49 | You can test it by visiting [http://container-ip:8080](http://container-ip:8080) 50 | -------------------------------------------------------------------------------- /docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DATA_PATH=${DATA_PATH:="/osrm-data"} 3 | 4 | _sig() { 5 | kill -TERM $child 2>/dev/null 6 | } 7 | 8 | if [ "$1" = 'osrm' ]; then 9 | trap _sig SIGKILL SIGTERM SIGHUP SIGINT EXIT 10 | 11 | if [ ! -f $DATA_PATH/$2.osrm ]; then 12 | if [ ! -f $DATA_PATH/$2.osm.pbf ]; then 13 | curl $3 > $DATA_PATH/$2.osm.pbf 14 | fi 15 | ./osrm-extract $DATA_PATH/$2.osm.pbf 16 | ./osrm-contract $DATA_PATH/$2.osrm 17 | fi 18 | 19 | ./osrm-routed $DATA_PATH/$2.osrm --max-table-size 8000 & 20 | child=$! 21 | wait "$child" 22 | else 23 | exec "$@" 24 | fi 25 | --------------------------------------------------------------------------------