Skip to content

Commit

Permalink
upstreaming some changes from @paulswartz fork (#11)
Browse files Browse the repository at this point in the history
* feat: also deploy to the local GHCR repository

* fix: stop the loop if the server crashes

* feat: only build the graph on BUILDPLATFORM

* feat: update APK packages

* fix: pretend we have elevation to prevent downloads

Even using `elevation: false` doesn't prevent the elevation download, so
we need to pretend our PBF has the data already.

* chore: update to 8.2.0

* fix: set acccess=yes if motor_vehicles=yes

This works around a bug in
ORS (GIScience/openrouteservice#704) where
`access=no` overrides the more specific `motor_vehicles=yes`.

Example way: https://www.openstreetmap.org/way/1111815406
  • Loading branch information
paulswartz authored Oct 18, 2024
1 parent 9fbe644 commit bf5fea4
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 17 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/deploy-to-ghcr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Deploy to GitHub Container Registry

on:
workflow_dispatch:
push:
branches: ["main"]
schedule:
# Runs every Monday and Thursday at 15:39 UTC, which is either
# 8:49 AM or 9:49 AM ET, depending on Daylight Savings Time. This
# is two hours before the prod deploy, so we can see how dev is
# doing before approving a prod deploy.
- cron: "49 13 * * 1,4"

env:
REGISTRY: ghcr.io
PLATFORMS: linux/amd64,linux/arm64
TAG: ghcr.io/${{ github.repository_owner }}/ors:latest

jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
platforms: ${{ env.PLATFORMS }}
tags: ${{ env.TAG }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.TAG }}
trivy-config: trivy.yml
16 changes: 10 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
ARG OPEN_ROUTE_SERVICE_VERSION=8.0.1
ARG OPEN_ROUTE_SERVICE_VERSION=8.2.0

FROM openrouteservice/openrouteservice:v${OPEN_ROUTE_SERVICE_VERSION} AS builder
FROM --platform=$BUILDPLATFORM openrouteservice/openrouteservice:v${OPEN_ROUTE_SERVICE_VERSION} AS builder

COPY preparation.sh /preparation.sh

RUN wget http://download.geofabrik.de/north-america/us/massachusetts-latest.osm.pbf -O files/data.osm.pbf
RUN <<EOT
apk add osmctools --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing
wget http://download.geofabrik.de/north-america/us/massachusetts-latest.osm.pbf -O files/data.osm.pbf
EOT

COPY preparation.sh /preparation.sh
COPY ors-config.yml config/ors-config.yml

COPY parameter-file /parameter-file
RUN /preparation.sh

FROM openrouteservice/openrouteservice:v${OPEN_ROUTE_SERVICE_VERSION}

RUN apk upgrade --no-cache -f --purge

COPY --from=builder /home/ors/graphs graphs
COPY ors-config.yml config/ors-config.yml
16 changes: 10 additions & 6 deletions ors-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@
ors:
engine:
source_file: /home/ors/files/data.osm.pbf
elevation:
# Disabling elevation for now because ORS tries to download
# elevation data from URL's that are not always available,
# which sometimes raises SocketTimeoutException's and prevents
# ORS from starting. See
# https://github.com/GIScience/openrouteservice/issues?q=is%3Aissue+java.net.SocketTimeoutException
# for more info
preprocessed: true

profiles:
car:
enabled: true
elevation: false

hgv:
enabled: true
Expand All @@ -18,12 +28,6 @@ ors:
block_fords: false
use_acceleration: true
maximum_distance: 100000
# Disabling elevation for now because ORS tries to download
# elevation data from URL's that are not always available,
# which sometimes raises SocketTimeoutException's and prevents
# ORS from starting. See
# https://github.com/GIScience/openrouteservice/issues?q=is%3Aissue+java.net.SocketTimeoutException
# for more info
elevation: false
preparation:
min_network_size: 200
Expand Down
4 changes: 4 additions & 0 deletions parameter-file
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--modify-tags=
access=no and motor_vehicle=yes
to
=yes
19 changes: 14 additions & 5 deletions preparation.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
#!/usr/bin/env bash
set -e

export REBUILD_GRAPHS=true
export ors.engine.preparation_mode=true
export ors.services.routing.mode=preparation
export ORS_ENGINE_PREPARATION_MODE=true
export ORS_SERVICES_ROUTING_MODE=preparation

mv files/data.osm.pbf original.pbf
osmconvert -v original.pbf --parameter-file=/parameter-file -o=files/data.osm.pbf
rm original.pbf

/entrypoint.sh &
entrypoint_pid=$!

# Wait for the server to become healthy...
while ! wget --quiet -O /dev/null http://localhost:8082/ors/v2/health; do
# Wait for the server to stop or become healthy...
while kill -0 $entrypoint_pid >/dev/null && ! wget --quiet -O /dev/null http://localhost:8082/ors/v2/health; do
sleep 5
done

echo Built graph, stopping server...
kill $entrypoint_pid
kill $entrypoint_pid || true

echo Checking that graphs were built...
test -d graphs/car || exit 1
test -d graphs/hgv || exit 1

0 comments on commit bf5fea4

Please sign in to comment.