-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from peter-evans/update-osrm
Update OSRM backend to version 5.21.0
- Loading branch information
Showing
6 changed files
with
126 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.