From bf5fea40325ff8ffdc20b599d6b2dba7fa35a8ea Mon Sep 17 00:00:00 2001 From: Paul Swartz Date: Fri, 18 Oct 2024 13:28:10 -0400 Subject: [PATCH] upstreaming some changes from @paulswartz fork (#11) * 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 (https://github.com/GIScience/openrouteservice/issues/704) where `access=no` overrides the more specific `motor_vehicles=yes`. Example way: https://www.openstreetmap.org/way/1111815406 --- .github/workflows/deploy-to-ghcr.yml | 47 ++++++++++++++++++++++++++++ Dockerfile | 16 ++++++---- ors-config.yml | 16 ++++++---- parameter-file | 4 +++ preparation.sh | 19 ++++++++--- 5 files changed, 85 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/deploy-to-ghcr.yml create mode 100644 parameter-file diff --git a/.github/workflows/deploy-to-ghcr.yml b/.github/workflows/deploy-to-ghcr.yml new file mode 100644 index 0000000..3d88c5d --- /dev/null +++ b/.github/workflows/deploy-to-ghcr.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index e2e4823..e5482a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 </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