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