Skip to content

Commit

Permalink
Merge pull request #53 from peter-evans/update-osrm
Browse files Browse the repository at this point in the history
Update OSRM backend to version 5.21.0
  • Loading branch information
peter-evans authored Dec 19, 2018
2 parents 135b023 + d4d2ac3 commit bece387
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
- docker

install:
- docker build -t osrm-backend-k8s ./1.19
- docker build -t osrm-backend-k8s ./1.20
- docker run -d -p 5000:5000 -e OSRM_PBF_URL='http://download.geofabrik.de/asia/maldives-latest.osm.pbf' --name osrm-backend osrm-backend-k8s

before_script:
Expand Down
57 changes: 57 additions & 0 deletions 1.20/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM peterevans/xenial-gcloud:1.2.21

MAINTAINER Peter Evans <pete.evans@gmail.com>

ENV OSRM_VERSION 5.21.0

# Let the container know that there is no TTY
ARG DEBIAN_FRONTEND=noninteractive

# Install packages
RUN apt-get -y update \
&& apt-get install -y -qq --no-install-recommends \
build-essential \
cmake \
curl \
libbz2-dev \
libstxxl-dev \
libstxxl1v5 \
libxml2-dev \
libzip-dev \
libboost-all-dev \
lua5.2 \
liblua5.2-dev \
libtbb-dev \
libluabind-dev \
pkg-config \
gcc \
python-dev \
python-setuptools \
&& apt-get clean \
&& easy_install -U pip \
&& pip install -U crcmod \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/* /var/tmp/*

# Build osrm-backend
RUN mkdir /osrm-src \
&& cd /osrm-src \
&& curl --silent -L https://github.com/Project-OSRM/osrm-backend/archive/v$OSRM_VERSION.tar.gz -o v$OSRM_VERSION.tar.gz \
&& tar xzf v$OSRM_VERSION.tar.gz \
&& cd osrm-backend-$OSRM_VERSION \
&& mkdir build \
&& cd build \
&& cmake .. -DCMAKE_BUILD_TYPE=Release \
&& cmake --build . \
&& cmake --build . --target install \
&& mkdir /osrm-data \
&& mkdir /osrm-profiles \
&& cp -r /osrm-src/osrm-backend-$OSRM_VERSION/profiles/* /osrm-profiles \
&& rm -rf /osrm-src

# Set the entrypoint
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]

EXPOSE 5000
66 changes: 66 additions & 0 deletions 1.20/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

if [ "$OSRM_MODE" != "CREATE" ] && [ "$OSRM_MODE" != "RESTORE" ]; then
# Default to CREATE
OSRM_MODE="CREATE"
fi

# Defaults
OSRM_DATA_PATH=${OSRM_DATA_PATH:="/osrm-data"}
OSRM_DATA_LABEL=${OSRM_DATA_LABEL:="data"}
OSRM_GRAPH_PROFILE=${OSRM_GRAPH_PROFILE:="car"}
OSRM_PBF_URL=${OSRM_PBF_URL:="http://download.geofabrik.de/asia/maldives-latest.osm.pbf"}
# Google Storage variables
OSRM_SA_KEY_PATH=${OSRM_SA_KEY_PATH:=""}
OSRM_PROJECT_ID=${OSRM_PROJECT_ID:=""}
OSRM_GS_BUCKET=${OSRM_GS_BUCKET:=""}
OSRM_MAX_TABLE_SIZE=${OSRM_MAX_TABLE_SIZE:="8000"}


_sig() {
kill -TERM $child 2>/dev/null
}
trap _sig SIGKILL SIGTERM SIGHUP SIGINT EXIT


if [ "$OSRM_MODE" == "CREATE" ]; then

# Retrieve the PBF file
curl -L $OSRM_PBF_URL --create-dirs -o $OSRM_DATA_PATH/$OSRM_DATA_LABEL.osm.pbf

# Build the graph
osrm-extract $OSRM_DATA_PATH/$OSRM_DATA_LABEL.osm.pbf -p /osrm-profiles/$OSRM_GRAPH_PROFILE.lua
osrm-contract $OSRM_DATA_PATH/$OSRM_DATA_LABEL.osrm

if [ ! -z "$OSRM_SA_KEY_PATH" ] && [ ! -z "$OSRM_PROJECT_ID" ] && [ ! -z "$OSRM_GS_BUCKET" ]; then

# Activate the service account to access storage
gcloud auth activate-service-account --key-file $OSRM_SA_KEY_PATH
# Set the Google Cloud project ID
gcloud config set project $OSRM_PROJECT_ID

# Copy the graph to storage
gsutil -m cp $OSRM_DATA_PATH/*.osrm* $OSRM_GS_BUCKET/$OSRM_DATA_LABEL

fi

else

if [ ! -z "$OSRM_SA_KEY_PATH" ] && [ ! -z "$OSRM_PROJECT_ID" ] && [ ! -z "$OSRM_GS_BUCKET" ]; then

# Activate the service account to access storage
gcloud auth activate-service-account --key-file $OSRM_SA_KEY_PATH
# Set the Google Cloud project ID
gcloud config set project $OSRM_PROJECT_ID

# Copy the graph from storage
gsutil -m cp $OSRM_GS_BUCKET/$OSRM_DATA_LABEL/*.osrm* $OSRM_DATA_PATH

fi

fi

# Start serving requests
osrm-routed $OSRM_DATA_PATH/$OSRM_DATA_LABEL.osrm --max-table-size $OSRM_MAX_TABLE_SIZE &
child=$!
wait "$child"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ If you are looking for a more general purpose docker image, see [osrm-backend-do

## Supported tags and respective `Dockerfile` links

- [`1.19.0`, `1.19`, `latest` (*1.19/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/1.19)
- [`1.20.0`, `1.20`, `latest` (*1.20/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/1.20)
- [`1.19.0`, `1.19` (*1.19/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/1.19)
- [`1.18.0`, `1.18` (*1.18/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/1.18)
- [`1.17.1`, `1.17` (*1.17/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/1.17)
- [`1.16.2`, `1.16` (*1.16/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/1.16)
Expand All @@ -19,7 +20,6 @@ If you are looking for a more general purpose docker image, see [osrm-backend-do
- [`1.13.3`, `1.13` (*1.13/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/1.13)
- [`1.12.0`, `1.12` (*1.12/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/1.12)
- [`1.11.0`, `1.11` (*1.11/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/1.11)
- [`1.10.0`, `1.10` (*1.10/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/1.10)

For earlier versions see [releases](https://github.com/peter-evans/osrm-backend-k8s/releases) and the available [tags on Docker Hub](https://hub.docker.com/r/peterevans/osrm-backend-k8s/tags/).

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit bece387

Please sign in to comment.