Skip to content

Commit

Permalink
Adding all the setup related files
Browse files Browse the repository at this point in the history
  • Loading branch information
rajendrakumaryadav committed Sep 8, 2024
1 parent a2bccff commit aa11157
Show file tree
Hide file tree
Showing 64 changed files with 3,922 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
test/custom_files
.git
**/*.pbf
**/*.tar
**/*.sqlite
*.md
25 changes: 25 additions & 0 deletions .github/workflows/manual_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Builds a new image from Valhalla's "manually_triggered_build" image

name: manual image build
on:
workflow_dispatch

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to GitHub Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build latest image
run: |
sed -i "s/:latest/:manually_triggered_build_amd64/g" Dockerfile
docker build -t ghcr.io/${{ github.repository }}/valhalla:manually_triggered_build_amd64 .
docker push ghcr.io/${{ github.repository }}/valhalla:manually_triggered_build_amd64
28 changes: 28 additions & 0 deletions .github/workflows/manual_build_arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: manual arm64 image build
on:
workflow_dispatch

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to GitHub Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
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 latest image
run: |
sed -i "s/:latest/:manually_triggered_build_arm64/g" Dockerfile
docker buildx build --push --platform linux/arm64 --tag ghcr.io/${{ github.repository }}/valhalla:manually_triggered_build_arm64 .
36 changes: 36 additions & 0 deletions .github/workflows/publish_latest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: publish latest
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 6'
push:
branches:
- 'master'
paths-ignore:
- '.gitignore'
- '**.md'
- '**.template'

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to GitHub Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
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 images
run: |
docker buildx build --push --platform linux/amd64,linux/arm64 --tag ghcr.io/${{ github.repository }}/valhalla:latest .
37 changes: 37 additions & 0 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: publish release
on:
push:
branches:
- '[1-9]+.[0-9]+.[0-9]+'
paths-ignore:
- '.gitignore'
- '**.md'
- '**.template'

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Extract branch name
run: echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}"
id: extract_branch

- name: Log in to GitHub Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
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 container image
run: |
docker buildx build --push --platform linux/amd64,linux/arm64 --tag ghcr.io/${{ github.repository }}/valhalla:${{ steps.extract_branch.outputs.branch }} .
39 changes: 39 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# be aware this won't test the auto-published
# weekly 'latest' images (generated "manually")
name: ci tests
on:
push:
paths-ignore:
- '.gitignore'
- '**.md'
- '**.template'
branches:
- '[1-9]+.[0-9]+.[0-9]+'
- master
pull_request:
paths-ignore:
- '.gitignore'
- '**.md'
- '**.template'
branches:
- master

jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build image
run: |
uid=$(id --user)
gid=$(id --group)
echo "Running one bare build and one with UID ${uid} and GID {$gid}"
docker build -t gisops/valhalla:latest .
docker build -t gisops/valhalla:latest_user_stuff --build-arg VALHALLA_UID=${uid} --build-arg VALHALLA_GID=${gid} .
- name: Test image
run : |
echo "Running with UID $(id --user) and GID $(id --group)"
sudo apt-get update > /dev/null
sudo apt-get install -y moreutils tree > /dev/null
sudo /bin/bash -c "./tests/test.sh gisops/valhalla:latest"
/bin/bash -c "./tests/test.sh gisops/valhalla:latest_user_stuff"
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
docker-compose.yml
custom_files/
*.pbf
!tests/*.pbf
*.tar
*.sqlite
70 changes: 70 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Take the official valhalla runner image,
# remove a few superfluous things and
# create a new runner image from ubuntu:22.04
# with the previous runner's artifacts
ARG VALHALLA_BUILDER_IMAGE=ghcr.io/valhalla/valhalla:latest
FROM $VALHALLA_BUILDER_IMAGE as builder
MAINTAINER Nils Nolde <nils@gis-ops.com>

# remove some stuff from the original image
RUN cd /usr/local/bin && \
preserve="valhalla_service valhalla_build_tiles valhalla_build_config valhalla_build_admins valhalla_build_timezones valhalla_build_elevation valhalla_ways_to_edges valhalla_build_extract valhalla_export_edges valhalla_add_predicted_traffic valhalla_ingest_transit valhalla_convert_transit valhalla_add_landmarks valhalla_build_landmarks" && \
mv $preserve .. && \
for f in valhalla*; do rm $f; done && \
cd .. && mv $preserve ./bin

FROM ubuntu:23.04 as runner_base
MAINTAINER Nils Nolde <nils@gis-ops.com>

RUN apt-get update > /dev/null && \
export DEBIAN_FRONTEND=noninteractive && \
apt-get install -y libluajit-5.1-2 libgdal32 \
libzmq5 libczmq4 spatialite-bin libprotobuf-lite32 sudo locales \
libsqlite3-0 libsqlite3-mod-spatialite libcurl4 \
python3.11-minimal python3-distutils curl unzip moreutils jq spatialite-bin python-is-python3 > /dev/null

COPY --from=builder /usr/local /usr/local
COPY --from=builder /usr/lib/python3/dist-packages/valhalla/* /usr/lib/python3/dist-packages/valhalla/

ENV LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}"
# export the True defaults
ENV use_tiles_ignore_pbf=True
ENV build_tar=True
ENV serve_tiles=True
ENV update_existing_config=True

ENV default_speeds_config_url="https://raw.githubusercontent.com/OpenStreetMapSpeeds/schema/master/default_speeds.json"

# what this does:
# if the docker user specified a UID/GID (other than 0, would be a ludicrous instruction anyways) in the image build, we will use that to create the valhalla linux user in the image. that ensures that the docker user can edit the created files on the host without sudo and with 664/775 permissions, so that users of that group can also write. the default is to give the valhalla user passwordless sudo. that also means that all commands creating files in the entrypoint script need to be executed with sudo when built with defaults..
# based on https://jtreminio.com/blog/running-docker-containers-as-current-host-user/, but this use case needed a more customized approach

# with that we can properly test if the default was used or not
ARG VALHALLA_UID=59999
ARG VALHALLA_GID=59999

RUN groupadd -g ${VALHALLA_GID} valhalla && \
useradd -lmu ${VALHALLA_UID} -g valhalla valhalla && \
mkdir /custom_files && \
if [ $VALHALLA_UID != 59999 ] || [ $VALHALLA_GID != 59999 ]; then chmod 0775 custom_files && chown valhalla:valhalla /custom_files; else usermod -aG sudo valhalla && echo "ALL ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers; fi

COPY scripts/. /valhalla/scripts

USER valhalla

WORKDIR /custom_files

# Smoke tests
RUN python -c "import valhalla,sys; print (sys.version, valhalla)" \
&& valhalla_build_config | jq type \
&& cat /usr/local/src/valhalla_version \
&& valhalla_build_tiles -v \
&& ls -la /usr/local/bin/valhalla*

ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
ENV LD_LIBRARY_PATH /usr/local/lib:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/lib32:/usr/lib32

# Expose the necessary port
EXPOSE 8002
ENTRYPOINT ["/valhalla/scripts/run.sh"]
CMD ["build_tiles"]
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 GIS • OPS UG

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
46 changes: 46 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
services:
valhalla:
image: ghcr.io/gis-ops/docker-valhalla/valhalla:latest
container_name: valhalla
hostname: valhalla
ports:
- "8002:8002"
build:
context: .
args:
- VALHALLA_UID=1000
- VALHALLA_GID=1000
volumes:
- ./custom_files/:/custom_files
# - ./gtfs_feeds:/gtfs_feeds # only enable with build_transit=True
environment:
- tile_urls=https://download.geofabrik.de/europe/andorra-latest.osm.pbf https://download.geofabrik.de/europe/albania-latest.osm.pbf
- server_threads=2 # determines how many threads will be used to run the valhalla server
- serve_tiles=True # If True, starts the service. If false, stops after building the graph.
- use_tiles_ignore_pbf=True # load existing valhalla_tiles.tar directly
- tileset_name=valhalla_tiles # name of the resulting graph on disk
- build_elevation=False # build elevation with "True" or "Force": will download only the elevation for areas covered by the graph tiles
- build_admins=False # build admins db with "True" or "Force"
- build_time_zones=False # build timezone db with "True" or "Force"
- build_transit=False # build transit, needs existing GTFS directories mapped to /gtfs_feeds
- build_tar=False # build an indexed tar file from the tile_dir for faster graph loading times
- force_rebuild=False # forces a rebuild of the routing tiles with "True"
- update_existing_config=False # if there are new config entries in the default config, add them to the existing config
# - path_extension=graphs # this path will be internally appended to /custom_files; no leading or trailing path separator!

vroom:
image: ghcr.io/vroom-project/vroom-docker:v1.14.0
container_name: vroom
hostname: vroom
volumes:
- ./conf:/conf
environment:
- VROOM_ROUTER=valhalla
ports:
- "3000:3000"
vroom-frontend:
image: vroom-frontend:latest
container_name: vroom-frontend
hostname: vroom-frontend
ports:
- "9966:9966"
43 changes: 43 additions & 0 deletions conf/access.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
::ffff:127.0.0.1 - - [08/Sep/2024:14:50:00 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:50:30 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:51:00 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:51:31 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:52:01 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:52:31 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:53:01 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:53:31 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:54:01 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:54:31 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:55:01 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:55:31 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:56:01 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:56:32 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:57:02 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:57:32 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:58:02 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:58:32 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:59:02 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:14:59:32 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:00:02 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:00:32 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:01:02 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:01:32 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:02:02 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:02:32 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:03:03 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:03:33 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:04:03 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:04:33 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:05:03 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:05:33 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:06:03 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:06:33 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:07:03 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:07:33 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:08:04 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:08:34 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:09:04 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:09:34 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:10:04 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:10:34 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
::ffff:127.0.0.1 - - [08/Sep/2024:15:11:04 +0000] "GET /health HTTP/1.1" 200 - "-" "curl/7.88.1"
Loading

0 comments on commit aa11157

Please sign in to comment.