Skip to content

Commit

Permalink
Merge pull request #55 from peter-evans/update-osrm
Browse files Browse the repository at this point in the history
Update OSRM backend to version 5.22.0
  • Loading branch information
peter-evans authored Mar 4, 2019
2 parents bece387 + 0f70f0a commit b569b0c
Show file tree
Hide file tree
Showing 25 changed files with 237 additions and 11 deletions.
107 changes: 107 additions & 0 deletions .circleci/config.yml
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: /.*/
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.20
- docker build -t osrm-backend-k8s .
- 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 Dockerfile
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
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# osrm-backend for Kubernetes
[![](https://images.microbadger.com/badges/image/peterevans/osrm-backend-k8s.svg)](https://microbadger.com/images/peterevans/osrm-backend-k8s)
[![Build Status](https://travis-ci.org/peter-evans/osrm-backend-k8s.svg?branch=master)](https://travis-ci.org/peter-evans/osrm-backend-k8s)
[![CircleCI](https://circleci.com/gh/peter-evans/osrm-backend-k8s/tree/master.svg?style=svg)](https://circleci.com/gh/peter-evans/osrm-backend-k8s/tree/master)

Open Source Routing Machine (OSRM) [osrm-backend](https://github.com/Project-OSRM/osrm-backend) for Kubernetes on Google Container Engine (GKE).

Expand All @@ -10,16 +11,11 @@ If you are looking for a more general purpose docker image, see [osrm-backend-do

## Supported tags and respective `Dockerfile` links

- [`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)
- [`1.15.7`, `1.15` (*1.15/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/1.15)
- [`1.14.3`, `1.14` (*1.14/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/1.14)
- [`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.21.0`, `1.21`, `latest` (*1.21/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master)
- [`1.20.0`, `1.20` (*1.20/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/archive/1.20)
- [`1.19.0`, `1.19` (*1.19/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/archive/1.19)
- [`1.18.0`, `1.18` (*1.18/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/archive/1.18)
- [`1.17.1`, `1.17` (*1.17/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/archive/1.17)

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.
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.
66 changes: 66 additions & 0 deletions 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"

0 comments on commit b569b0c

Please sign in to comment.