-
-
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 #55 from peter-evans/update-osrm
Update OSRM backend to version 5.22.0
- Loading branch information
Showing
25 changed files
with
237 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
version: 2.1 | ||
executors: | ||
docker-executor: | ||
environment: | ||
IMAGE_NAME: peterevans/osrm-backend-k8s | ||
OSRM_PBF_URL: http://download.geofabrik.de/asia/maldives-latest.osm.pbf | ||
docker: | ||
- image: circleci/buildpack-deps:stretch | ||
jobs: | ||
build: | ||
executor: docker-executor | ||
environment: | ||
IMAGE_TAG: latest | ||
DOCKERFILE_PATH: . | ||
steps: | ||
- checkout | ||
- setup_remote_docker: | ||
docker_layer_caching: true | ||
- run: | ||
name: Build Docker image | ||
command: | | ||
docker build -t $IMAGE_NAME:$IMAGE_TAG $DOCKERFILE_PATH | ||
- run: | ||
name: Cache Docker image | ||
command: docker save -o $IMAGE_TAG.tar $IMAGE_NAME | ||
- persist_to_workspace: | ||
root: . | ||
paths: | ||
- ./*.tar | ||
test: | ||
executor: docker-executor | ||
steps: | ||
- checkout | ||
- attach_workspace: | ||
at: /tmp/workspace | ||
- setup_remote_docker | ||
- run: | ||
name: Load cached Docker image | ||
command: | | ||
docker load -i /tmp/workspace/latest.tar | ||
- run: | ||
name: Test Docker image | ||
command: | | ||
docker run -d -e OSRM_PBF_URL=$OSRM_PBF_URL --name osrm-backend-k8s $IMAGE_NAME:latest | ||
# Dummy container to store tests | ||
docker create -v /etc/newman --name tests alpine:3.4 /bin/true | ||
docker cp tests/. tests:/etc/newman | ||
# Run tests | ||
docker run --network container:osrm-backend-k8s jwilder/dockerize -wait http://localhost:5000/nearest/v1/healthz/0,0 -timeout 120s -wait-retry-interval 5s | ||
docker run --network container:osrm-backend-k8s --volumes-from tests -t postman/newman:4.4.0-alpine run osrm_backend.postman_collection.json | ||
publish-tag: | ||
executor: docker-executor | ||
steps: | ||
- attach_workspace: | ||
at: /tmp/workspace | ||
- setup_remote_docker | ||
- run: | ||
name: Load cached Docker image | ||
command: | | ||
docker load -i /tmp/workspace/latest.tar | ||
- run: | ||
name: Publish Docker Image to Docker Hub | ||
command: | | ||
echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin | ||
IMAGE_TAG=${CIRCLE_TAG/v/''} | ||
docker tag $IMAGE_NAME:latest $IMAGE_NAME:$IMAGE_TAG | ||
docker push $IMAGE_NAME:latest | ||
docker push $IMAGE_NAME:$IMAGE_TAG | ||
# If the minor version can be extracted then tag and push | ||
MINOR_VERSION=$(echo $CIRCLE_TAG | sed -n "s/^v\([0-9]*.[0-9]*\).[0-9]*$/\1/p") | ||
if [[ ${#MINOR_VERSION} -gt 0 ]]; then | ||
docker tag $IMAGE_NAME:latest $IMAGE_NAME:$MINOR_VERSION | ||
docker push $IMAGE_NAME:$MINOR_VERSION | ||
fi | ||
workflows: | ||
version: 2 | ||
build: | ||
jobs: | ||
- build | ||
- test: | ||
requires: | ||
- build | ||
build-and-publish-tags: | ||
jobs: | ||
- build: | ||
filters: | ||
tags: | ||
only: /^v.*/ | ||
branches: | ||
ignore: /.*/ | ||
- test: | ||
requires: | ||
- build | ||
filters: | ||
tags: | ||
only: /^v.*/ | ||
branches: | ||
ignore: /.*/ | ||
- publish-tag: | ||
context: org-global | ||
requires: | ||
- test | ||
filters: | ||
tags: | ||
only: /^v.*/ | ||
branches: | ||
ignore: /.*/ |
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.22 | ||
|
||
MAINTAINER Peter Evans <pete.evans@gmail.com> | ||
|
||
ENV OSRM_VERSION 5.22.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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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" |