diff --git a/.dockerignore b/.dockerignore index 7bc9742d68..d928e85bfa 100644 --- a/.dockerignore +++ b/.dockerignore @@ -25,6 +25,7 @@ ors-api/logs ors-api/target/ ors-engine/target/ +ors-docker/** cgiar_provider/ cgiar_cache/ diff --git a/.github/utils/config_conversion.sh b/.github/utils/config_conversion.sh deleted file mode 100755 index 8eac250326..0000000000 --- a/.github/utils/config_conversion.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -if [ "$#" -ne 2 ]; then - echo "Usage: $0 input.yaml output.yaml" - exit 1 -fi - -input_file=$1 -output_file=$2 -ors_file="ors-api/src/test/files/heidelberg.osm.gz" - -########################### -### Validate input file ### -########################### -# Fail if ors: can't be found -echo "Checking for ors section" -awk '/^ors:/{print "Found ors section"}' "$input_file" || exit 1 - -# For engine and source file section, make sure they are in place -echo "Checking for engine and source_file section" -awk '/ engine:/{getline; if ($0 ~ /source_file:/) {print "Found engine and source_file section"} else { exit 1 }}' "$input_file" || exit 1 - -# For profiles section for car wit enabled -echo "Checking for profiles section" -awk '/ profiles:/{getline; if ($0 ~ / car:/) {getline; if ($0 ~ / enabled:/) {print "Found profiles section"} else { exit 1 }}}' "$input_file" || exit 1 - -########################### -### Convert input file #### -########################### -# Add # to the beginning of each line that is not empty or a comment -awk '!/^[[:space:]]*#/ && !/^[[:space:]]*$/ {print "#" $0; next} {print}' "$input_file" > "$output_file" - -# Replace '#ors:' with 'ors:' -sed -i 's/#ors:/ors:/g' "$output_file" - - -# Remove the comments for the engine and source_file section -awk -i inplace "/engine:/{getline; if (\$0 ~ /source_file:/) {print \" engine:\"; print \" source_file: '$ors_file'\"; next} else { exit1 }} {print}" "$output_file" - -# Remove the comments for the profiles section for car -awk -i inplace "/# profiles:/{getline; if (\$0 ~ /# car:/) {getline; if (\$0 ~ /# enabled:/) {print \" profiles:\"; print \" car:\"; print \" enabled: true\"; next}}}{print}" "$output_file" - -echo "Parsing complete. Result saved to $output_file" diff --git a/.github/utils/yml_config_to_ors_config_conversion.sh b/.github/utils/yml_config_to_ors_config_conversion.sh new file mode 100755 index 0000000000..2a73095832 --- /dev/null +++ b/.github/utils/yml_config_to_ors_config_conversion.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +if [ "$#" -ne 2 ]; then + echo "Usage: $0 input.yaml output.yaml" + exit 1 +fi + +input_file=$1 +output_file=$2 + +echo "" +echo "Copy $input_file to $output_file" +cp $input_file $output_file + +########################### +### Replace parameters #### +########################### +echo "" +echo "Replace parameters:" + +echo "- enable ors.engine.profiles.car" +yq -i '.ors.engine.profiles.car.enabled = true' "$output_file" || exit 1 + +echo "- set ors.engine.source_file to ors-api/src/test/files/heidelberg.osm.gz" +yq -i '.ors.engine.source_file = "ors-api/src/test/files/heidelberg.osm.gz"' "$output_file" || exit 1 + +########################### +### Convert input file #### +########################### +echo "" +echo "Converting input file:" +## Add # to the beginning of each line that is not empty or a comment +echo "- Comment everything" +sed -i '/^\s*[^#]/ s/^/#/' "$output_file" || exit 1 + +echo "- Uncomment ors, engine and source_file" +sed -i -e '/^#ors:/s/^#//' -e '/^#.*engine:/s/^#//' -e '/^#.*source_file:/s/^#//' "$output_file" + +echo "- Uncomment subsequent lines for profiles.car.enabled in ors.engine" +sed -i -e '/^# profiles:/,/^# enabled:/ s/^#//' "$output_file" + +echo "Parsing complete. Result saved to $output_file" diff --git a/.github/utils/yml_config_to_properties_conversion.sh b/.github/utils/yml_config_to_properties_conversion.sh new file mode 100755 index 0000000000..e93c44bb4b --- /dev/null +++ b/.github/utils/yml_config_to_properties_conversion.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +if [ "$#" -ne 2 ]; then + echo "Usage: $0 input.yaml output.properties" + exit 1 +fi + +input_file=$1 +output_file=$2 + +echo "" +echo "Copy $input_file to $output_file" +cp $input_file $output_file + +########################### +### Replace parameters #### +########################### +echo "" +echo "Replace parameters:" + +echo "- enable ors.engine.profiles.car" +yq -i '.ors.engine.profiles.car.enabled = true' "$output_file" || exit 1 + +echo "- set ors.engine.source_file to ors-api/src/test/files/heidelberg.osm.gz" +yq -i '.ors.engine.source_file = "ors-api/src/test/files/heidelberg.osm.gz"' "$output_file" || exit 1 + + +########################### +### Convert input file #### +########################### +echo "" +echo "Convert .yaml to .env/properties file:" +echo "- unwrap yaml structure to flat properties" +yq -i -o=props --unwrapScalar=false '.. | select(tag != "!!map" and tag != "!!seq") | ( (path | join(".")) + "=" + .)' "$output_file" || exit 1 + +## Add # to the beginning of each line that is not empty or a comment +echo "- Comment everything" +sed -i '/^\s*[^#]/ s/^/#/' "$output_file" || exit 1 + +echo "- Uncomment ors.engine.source_file and ors.engine.profiles.car.enabled" +sed -i -e '/^#ors.engine.source_file/s/^#//' -e '/^#ors.engine.profiles.car.enabled/s/^#//' "$output_file" || exit 1 + +############################ +### Validate output file ### +############################ +echo "" +echo "Validate output file:" +echo "- checking for ors.engine.source_file=ors-api/src/test/files/heidelberg.osm.gz" +return_value=$(sed -n '/^ors.engine.source_file=ors-api\/src\/test\/files\/heidelberg.osm.gz/p' $output_file)|| exit 1 +if [ -z "$return_value" ]; then + echo "ors.engine.source_file=ors-api/src/test/files/heidelberg.osm.gz not found" + exit 1 +fi +echo "- checking for ors.engine.profiles.car.enabled=true" +return_value=$(sed -n '/^ors.engine.profiles.car.enabled=true/p' $output_file) || exit 1 +if [ -z "$return_value" ]; then + echo "ors.engine.profiles.car.enabled=true not found" + exit 1 +fi + +echo "Parsing complete. Result saved to $output_file" + diff --git a/.github/utils/yml_config_validation.sh b/.github/utils/yml_config_validation.sh new file mode 100755 index 0000000000..fe615b1a7c --- /dev/null +++ b/.github/utils/yml_config_validation.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 input.yaml" + exit 1 +fi + +input_file=$1 + +########################### +### Validate input file ### +########################### +echo "Validate input file:" +echo "- checking if the input file is a valid yaml file" +yq 'true' $input_file /dev/null || exit 1 +# Fail if ors.engine.profiles.car.enabled='false' can't be found access with schema .result | select(.property_history != null) | .property_history | map(select(.event_name == "Sold"))[0].date' +echo "- checking if ors.engine.source_file exists and has 'source_file' property" +yq --exit-status '.ors.engine | has("source_file")' $input_file > /dev/null || exit 1 +# For profiles section for car with enabled using yq and contains +echo "- checking if ors.engine.profiles.car exists and has 'enabled' property" +yq --exit-status '.ors.engine.profiles.car | has("enabled")' $input_file > /dev/null || exit 1 \ No newline at end of file diff --git a/.github/workflows/config-conversion-automation.yml b/.github/workflows/config-conversion-automation.yml index 9499e22611..4332104191 100644 --- a/.github/workflows/config-conversion-automation.yml +++ b/.github/workflows/config-conversion-automation.yml @@ -1,4 +1,4 @@ -name: Automatic synchronization of application.yml to ors-config.yml +name: Automatic synchronization of application.yml to ors-config.yml and ors-config.env on: pull_request: branches: @@ -10,7 +10,7 @@ on: jobs: sync_config: - name: Synchronize changes in application.yml to ors-config.yml + name: Synchronize changes in application.yml to ors-config.yml and ors-config.env runs-on: ubuntu-latest permissions: contents: write @@ -20,10 +20,16 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} - - name: Convert application.yml to ors-config.yml + - name: yq - portable yaml processor + uses: mikefarah/yq@v4.40.5 + - name: validate application.yml + run: .github/utils/yml_config_validation.sh ors-api/src/main/resources/application.yml + - name: Convert application.yml to ors-config.yml and ors-config.env run: | - .github/utils/config_conversion.sh ors-api/src/main/resources/application.yml ors-config.yml + # Print yq version + yq --version + .github/utils/yml_config_to_ors_config_conversion.sh ors-api/src/main/resources/application.yml ors-config.yml + .github/utils/yml_config_to_properties_conversion.sh ors-api/src/main/resources/application.yml ors-config.env - uses: MichaelsJP/git-auto-commit-action@v5 with: - commit_message: 'chore(config): automatic conversion of application.yml to ors-config.yml' - + commit_message: 'chore(config): automatic conversion of application.yml to ors-config.yml and ors-config.env' diff --git a/.github/workflows/docker-build-and-test.yml b/.github/workflows/docker-build-and-test.yml index 3e829c98b5..34f41ada60 100644 --- a/.github/workflows/docker-build-and-test.yml +++ b/.github/workflows/docker-build-and-test.yml @@ -38,7 +38,7 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 id: buildx with: install: true @@ -95,7 +95,7 @@ jobs: with: platforms: ${{ matrix.platform }} - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 id: buildx with: install: true @@ -116,16 +116,27 @@ jobs: cache-from: type=gha - name: Start container from previously build image and wait for successful checks run: | - mkdir -p $(pwd)/graphs $(pwd)/conf - chown -R $UID $(pwd)/graphs $(pwd)/conf - docker run -it --user $UID -d -p 8080:8080 -v $(pwd)/graphs:/home/ors/ors-core/data/graphs -v $(pwd)/conf:/home/ors/ors-conf --name ors-instance ${{ needs.prepare_environment.outputs.test_image_name }} + mkdir -p $(pwd)/graphs $(pwd)/config + chown -R $UID $(pwd)/graphs $(pwd)/config + # Replace image: in the docker-compose.yml with the test image. The value of image: can vary. + sed -i "s|image:.*|image: ${{ needs.prepare_environment.outputs.test_image_name }}|" docker-compose.yml + # Start the first build with the docker-compose setup + docker compose up --build -d + # Wait for all logs to come in + sleep 5 + docker compose logs ors-app + ./.github/utils/url_check.sh 127.0.0.1 8080 /ors/v2/health 200 ${{ env.HEALTH_WAIT_TIME }} + # Stop the compose setup and continue with docker run + docker compose down + # Start the container with the test image and the raw docker run command + docker run -it --user $UID -d -p 8080:8082 -v $(pwd)/graphs:/home/ors/graphs -v $(pwd)/config:/home/ors/config --name ors-instance ${{ needs.prepare_environment.outputs.test_image_name }} # Check for health to turn 200 after the graphs are build and spring-boot completely started ./.github/utils/url_check.sh 127.0.0.1 8080 /ors/v2/health 200 ${{ env.HEALTH_WAIT_TIME }} # Check for correct preflight settings to avoid CORS issues with ORIGIN wildcard from the example config ./.github/utils/cors_check.sh 127.0.0.1 8080 /ors/v2/isochrones/geojson "https://example.org" 200 10 ./.github/utils/cors_check.sh 127.0.0.1 8080 /ors/v2/isochrones/geojson "https://example.com" 200 10 echo "Adjust the config file and set ORIGIN to https://example.org" - sudo yq '.ors.cors.allowed_origins = "https://example.org, https://test.com, http://localhost:8080"' -i ./conf/ors-config.yml + sudo yq '.ors.cors.allowed_origins = "https://example.org, https://test.com, http://localhost:8080"' -i $(pwd)/config/ors-config.yml # Restart the container to apply the config changes docker restart ors-instance # Request preflight with https://example.com and https://example.org to see if it gets applied correctly @@ -135,8 +146,8 @@ jobs: echo "Recreate the container to test if the graph can be properly read again" docker stop ors-instance docker container prune -f - chown -R $UID $(pwd)/graphs $(pwd)/conf - docker run -it --user $UID -d -p 8080:8080 -v $(pwd)/graphs:/home/ors/ors-core/data/graphs -v $(pwd)/conf:/home/ors/ors-conf --name ors-instance ${{ needs.prepare_environment.outputs.test_image_name }} + chown -R $UID $(pwd)/graphs $(pwd)/config + docker run -it --user $UID -d -p 8080:8082 -v $(pwd)/graphs:/home/ors/graphs -v $(pwd)/config:/home/ors/config -e ors.cors.allowed_origins=https://example.org --name ors-instance ${{ needs.prepare_environment.outputs.test_image_name }} # Request preflight with https://example.com and https://example.org to see if it gets applied correctly ./.github/utils/cors_check.sh 127.0.0.1 8080 /ors/v2/isochrones/geojson "https://example.org" 200 50 # It should fail with http code 403 for https://example.com since the Origin is not covered. diff --git a/.github/workflows/publish-tagged-release.yml b/.github/workflows/publish-tagged-release.yml index 594f37e740..ef5255abb3 100644 --- a/.github/workflows/publish-tagged-release.yml +++ b/.github/workflows/publish-tagged-release.yml @@ -20,14 +20,9 @@ jobs: id: buildx with: install: true - - name: 'Get Previous tag' - id: previoustag - uses: "WyriHaximus/github-action-get-previous-tag@v1" - - name: 'Get next minor version' - id: semvers - uses: "WyriHaximus/github-action-next-semvers@v1" - with: - version: ${{ steps.previoustag.outputs.tag }} + - name: Get the release tag + id: get_tag + run: echo ::set-output name=tag::${{ github.event.release.tag_name }} - name: Prepare id: prepare run: | @@ -42,13 +37,11 @@ jobs: DOCKER_IMAGE=openrouteservice/openrouteservice CURRENT_VERSIONS=$(test_version) - LATEST_IMAGE_VERSION=${{ steps.previoustag.outputs.tag }} - HIGHEST_IMAGE_VERSION=${{ steps.semvers.outputs.v_mayor }} + LATEST_IMAGE_VERSION=${{ steps.get_tag.outputs.tag }} DOCKER_PLATFORMS=linux/amd64,linux/arm64 BUILD_VERSION=true TAGS_LATEST_VERSION="${DOCKER_IMAGE}:${LATEST_IMAGE_VERSION}" - TAGS_HIGHEST_VERSION="${DOCKER_IMAGE}:${HIGHEST_IMAGE_VERSION}" echo "HIGHEST MAYOR VERSION: $TAGS_HIGHEST_VERSION" TAGS_LATEST="${DOCKER_IMAGE}:latest" @@ -60,7 +53,7 @@ jobs: echo ::set-output name=build_version::${BUILD_VERSION} echo ::set-output name=build_platforms::${DOCKER_PLATFORMS} - echo ::set-output name=buildx_tags_version::${TAGS_LATEST_VERSION} + echo ::set-output name=buildx_tags_version::${TAGS_LATEST_VERSION} echo ::set-output name=buildx_tags_latest::${TAGS_LATEST} - name: Login to DockerHub if: ${{ steps.prepare.outputs.build_version == 'true' }} @@ -72,7 +65,7 @@ jobs: if: ${{ steps.prepare.outputs.build_version == 'true' }} uses: actions/checkout@v4 with: - ref: ${{ steps.previoustag.outputs.tag }} + ref: ${{ steps.get_tag.outputs.tag }} - name: Build and publish version if needed if: ${{ steps.prepare.outputs.build_version == 'true' }} uses: docker/build-push-action@v4 @@ -83,3 +76,47 @@ jobs: platforms: ${{ steps.prepare.outputs.build_platforms }} cache-from: type=gha cache-to: type=gha,mode=max + build_and_publish_release_artifacts: + runs-on: ubuntu-latest + needs: build_and_publish_docker + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + cache: 'maven' + cache-dependency-path: ./pom.xml + - name: Build JAR + run: | + mvn -q clean package -DskipTests + # Copy the JAR to the root directory + cp ors-api/target/ors.jar ors.jar + - name: Build WAR + run: | + mvn -q clean package -DskipTests -PbuildWar + # Copy the WAR to the root directory + cp ors-api/target/ors.war ors.war + - name: Get the release tag + id: get_tag + run: echo ::set-output name=tag::${{ github.event.release.tag_name }} + - name: Rewrite the docker-compose.yml image tag to the release tag + if: startsWith(github.ref, 'refs/tags/') + run: | + # Replace the image part + sed -i "s/local\/openrouteservice:latest/openrouteservice\/openrouteservice:${{ steps.get_tag.outputs.tag }}/g" docker-compose.yml + - name: Attach the files to the release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + token: ${{ secrets.GITHUB_TOKEN }} + files: | + ./ors.jar + ./ors.war + ./ors-config.yml + ./ors-config.env + ./docker-compose.yml \ No newline at end of file diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml deleted file mode 100644 index 860f0e52c0..0000000000 --- a/.github/workflows/release-artifacts.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Build the release artifacts and attach them to the release - -on: - release: - types: [ created ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '17' - cache: 'maven' - cache-dependency-path: ./pom.xml - - name: Build JAR - run: | - mvn clean package -DskipTests - # Copy the JAR to the root directory - cp ors-api/target/ors.jar ors.jar - - - name: Build WAR - run: | - mvn clean package -DskipTests -PbuildWar - # Copy the WAR to the root directory - cp ors-api/target/ors.war ors.war - - - name: Attach the files to the release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - token: ${{ secrets.GITHUB_TOKEN }} - files: | - ./ors.jar - ./ors.war - ./ors-config.yml - ./ors-config.env \ No newline at end of file diff --git a/.gitignore b/.gitignore index c85f87c1fc..5867765681 100644 --- a/.gitignore +++ b/.gitignore @@ -16,11 +16,13 @@ node_modules/ .jqwik-database # Ignore folders generated from docker -docker/ +/config/ +/files/ # Ignore all ors-config files except for the sample one, useful for development and testing ors-api/src/main/resources/ors-config* ors-config* +ors-docker/** envs/ ors-config-repo/ diff --git a/Dockerfile b/Dockerfile index b7a01e2d13..e86603730c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,98 +1,61 @@ -# Image is reused in the workflow builds for main and the latest version -FROM maven:3.8-openjdk-17-slim as base - +# Image is reused in the workflow builds for master and the latest version +FROM docker.io/maven:3.8.7-openjdk-18-slim AS build ARG DEBIAN_FRONTEND=noninteractive - # hadolint ignore=DL3002 USER root -# Install dependencies and locales -# hadolint ignore=DL3008 -RUN apt-get update -qq && \ - apt-get install -qq -y --no-install-recommends nano moreutils jq wget && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -FROM base as tomcat -ARG TOMCAT_MAJOR=10 -ARG TOMCAT_VERSION=10.1.11 - -# hadolint ignore=DL3002 -USER root +WORKDIR /tmp/ors -WORKDIR /tmp -# Prepare tomcat -RUN wget -q https://archive.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR}/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz -O /tmp/tomcat.tar.gz && \ - tar xf tomcat.tar.gz && \ - mv /tmp/apache-tomcat-${TOMCAT_VERSION}/ /tmp/tomcat && \ - echo "org.apache.catalina.level = WARNING" >> /tmp/tomcat/conf/logging.properties +COPY ors-api /tmp/ors/ors-api +COPY ors-engine /tmp/ors/ors-engine +COPY pom.xml /tmp/ors/pom.xml +COPY ors-report-aggregation /tmp/ors/ors-report-aggregation -FROM base as build +# Build the project +RUN mvn -q clean package -DskipTests -# hadolint ignore=DL3002 -USER root - -ENV MAVEN_OPTS="-Dmaven.repo.local=.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" -ENV MAVEN_CLI_OPTS="--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true" - -WORKDIR /ors-core - -COPY ors-api /ors-core/ors-api -COPY ors-engine /ors-core/ors-engine -COPY pom.xml /ors-core/pom.xml -COPY ors-report-aggregation /ors-core/ors-report-aggregation - -# Build the project and ignore the report aggregation module as not needed for the API build war -RUN mvn package -DskipTests -P buildWar +# Copy the example config files to the build folder +COPY ./ors-config.yml /tmp/ors/example-ors-config.yml +COPY ./ors-config.env /tmp/ors/example-ors-config.env +# Rewrite the example config to use the right files in the container +RUN sed -i "/ors.engine.source_file=.*/s/.*/ors.engine.source_file=\/home\/ors\/files\/example-heidelberg.osm.gz/" "/tmp/ors/example-ors-config.env" && \ + sed -i "/ source_file:.*/s/.*/ source_file: \/home\/ors\/files\/example-heidelberg.osm.gz/" "/tmp/ors/example-ors-config.yml" # build final image, just copying stuff inside -FROM amazoncorretto:17.0.7-alpine3.17 as publish +FROM docker.io/amazoncorretto:21.0.2-alpine3.19 AS publish # Build ARGS ARG UID=1000 ARG GID=1000 ARG OSM_FILE=./ors-api/src/test/files/heidelberg.osm.gz -ARG BASE_FOLDER=/home/ors - -# Runtime ENVs for tomcat -ENV CATALINA_BASE=${BASE_FOLDER}/tomcat -ENV CATALINA_HOME=${BASE_FOLDER}/tomcat -ENV CATALINA_PID=${BASE_FOLDER}/tomcat/temp/tomcat.pid +ARG ORS_HOME=/home/ors # Set the default language ENV LANG='en_US' LANGUAGE='en_US' LC_ALL='en_US' # Setup the target system with the right user and folders. -RUN apk add --no-cache bash=~'5' openssl=~'3' && \ - addgroup -g ${GID} ors && \ - adduser -D -h ${BASE_FOLDER} -u ${UID} -G ors ors && \ - mkdir -p ${BASE_FOLDER}/ors-core/logs ${BASE_FOLDER}/ors-conf ${BASE_FOLDER}/ors-core/data ${BASE_FOLDER}/tomcat/logs && \ - chown -R ors ${BASE_FOLDER}/tomcat ${BASE_FOLDER}/ors-core/logs ${BASE_FOLDER}/ors-conf ${BASE_FOLDER}/ors-core/data ${BASE_FOLDER}/tomcat/logs - -WORKDIR ${BASE_FOLDER} +RUN apk update && apk add --no-cache bash yq jq && \ + addgroup ors -g ${GID} && \ + mkdir -p ${ORS_HOME}/logs ${ORS_HOME}/files ${ORS_HOME}/graphs ${ORS_HOME}/elevation_cache && \ + adduser -D -h ${ORS_HOME} -u ${UID} --system -G ors ors && \ + chown ors:ors ${ORS_HOME} \ + # Give all permissions to the user + && chmod -R 777 ${ORS_HOME} # Copy over the needed bits and pieces from the other stages. -COPY --chown=ors:ors --from=tomcat /tmp/tomcat ${BASE_FOLDER}/tomcat -COPY --chown=ors:ors --from=build /ors-core/ors-api/target/ors.war ${BASE_FOLDER}/tomcat/webapps/ors.war -COPY --chown=ors:ors ./docker-entrypoint.sh ${BASE_FOLDER}/docker-entrypoint.sh -COPY --chown=ors:ors ./ors-config.yml ${BASE_FOLDER}/tmp/ors-config.yml -COPY --chown=ors:ors ./$OSM_FILE ${BASE_FOLDER}/tmp/osm_file.pbf - -USER ${UID}:${GID} +COPY --chown=ors:ors --from=build /tmp/ors/ors-api/target/ors.jar /ors.jar +COPY --chown=ors:ors --from=build /tmp/ors/example-ors-config.yml /example-ors-config.yml +COPY --chown=ors:ors --from=build /tmp/ors/example-ors-config.env /example-ors-config.env +COPY --chown=ors:ors ./$OSM_FILE /heidelberg.osm.gz +COPY --chown=ors:ors ./docker-entrypoint.sh /entrypoint.sh -# Rewrite the ' source_file: ors-api/src/test/files/heidelberg.osm.gz' line in the config file to ' source_file: ${BASE_FOLDER}/ors-core/data/osm_file.pbf' -RUN sed -i "s| source_file: ors-api/src/test/files/heidelberg.osm.gz| source_file: ${BASE_FOLDER}/ors-core/data/osm_file.pbf|g" ${BASE_FOLDER}/tmp/ors-config.yml -# Rewrite the '# graphs_root_path: ./graphs' line in the config file to ' graphs_root_path: ${BASE_FOLDER}/ors-core/data/graphs' -RUN sed -i "s|# graphs_root_path: ./graphs| graphs_root_path: ${BASE_FOLDER}/ors-core/data/graphs|g" ${BASE_FOLDER}/tmp/ors-config.yml -# Rewrite the '# elevation:' line in the config file to ' elevation:' -RUN sed -i "s|# elevation:| elevation:|g" ${BASE_FOLDER}/tmp/ors-config.yml -# Rewrite the '# cache_path: ./elevation_cache' line in the config file to ' cache_path: ${BASE_FOLDER}/ors-core/data/elevation_cache' -RUN sed -i "s|# cache_path: ./elevation_cache| cache_path: ${BASE_FOLDER}/ors-core/data/elevation_cache|g" ${BASE_FOLDER}/tmp/ors-config.yml ENV BUILD_GRAPHS="False" -ENV ORS_CONFIG_LOCATION=ors-conf/ors-config.yml +ENV REBUILD_GRAPHS="False" +# Set the ARG to an ENV. Else it will be lost. +ENV ORS_HOME=${ORS_HOME} +WORKDIR ${ORS_HOME} # Start the container -ENTRYPOINT ["/home/ors/docker-entrypoint.sh"] -CMD ["/home/ors"] \ No newline at end of file +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index 53056371ee..97121a0b12 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ sed -i='' "s/openrouteservice\/openrouteservice:latest/openrouteservice\/openrou docker compose up -d ``` -For more details, check the [docker installation guide](https://giscience.github.io/openrouteservice/run-instance/installation/running-with-docker). +For more details, check the [docker installation guide](https://giscience.github.io/openrouteservice/run-instance/running-with-docker). For instructions on how to [build from source](https://giscience.github.io/openrouteservice/run-instance/installation/building-from-source) or [configure](https://giscience.github.io/openrouteservice/openrouteservice/run-instance/configuration/), visit our [Installation Instructions](https://giscience.github.io/openrouteservice/openrouteservice/run-instance/installation/). @@ -74,7 +74,7 @@ Openrouteservice offers a set of endpoints for different spatial purposes. By de - `http://localhost:8080/ors/v2/isochrones` - `http://localhost:8080/ors/v2/matrix` -You can find more information in the [Installation Instructions](https://giscience.github.io/openrouteservice/run-instance/installation/running-with-docker). +You can find more information in the [Installation Instructions](https://giscience.github.io/openrouteservice/run-instance/running-with-docker). ## API Documentation diff --git a/docker-compose.yml b/docker-compose.yml index 11bb9eba78..c2c3936b5e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,26 +1,84 @@ -version: '2.4' +# Docker Compose file for the openrouteservice (ORS) application +# Documentation and examples can be found on https://giscience.github.io/openrouteservice/run-instance/running-with-docker +version: '3.8' + services: + # ----------------- ORS application configuration ------------------- # ors-app: + # Activate the following lines to build the container from the repository + # You have to add --build to the docker compose command to do so + build: + context: ./ container_name: ors-app ports: - - "8080:8080" - - "9001:9001" - image: openrouteservice/openrouteservice:nightly - # For versioned images see https://giscience.github.io/openrouteservice/run-instance/installation/running-with-docker - user: "${UID:-0}:${GID:-0}" -# build: -# context: ./ -# args: -# OSM_FILE: ./ors-api/src/test/files/heidelberg.osm.gz - volumes: - - ./docker/graphs:/home/ors/ors-core/data/graphs - - ./docker/elevation_cache:/home/ors/ors-core/data/elevation_cache - - ./docker/logs/ors:/home/ors/logs - - ./docker/logs/tomcat:/home/ors/tomcat/logs - - ./docker/conf:/home/ors/ors-conf - - ./docker/data:/home/ors/ors-core/data + - "8080:8082" # Expose the ORS API on port 8080 + - "9001:9001" # Expose additional port for monitoring (optional) + image: local/openrouteservice:latest + # Advanced option! If you different ids to 0:0 and 1000:1000, you have to rebuild the container with the build args UID,GID. + # The user command is useful if you want easier bind mount access or better security. + #user: "1000:1000" # Run "mkdir -p ors && sudo chown -R 1000:1000 ors" before starting the container! + volumes: # Mount relative directories. ONLY for local container runtime. To switch to docker managed volumes see 'Docker Volumes configuration' section below. + - ./ors-docker:/home/ors # Mount the ORS application directory (for logs, graphs, elevation_cache, etc.) into its own directory + #- ./graphs:/home/ors/graphs # Mount graphs directory individually + #- ./elevation_cache:/home/ors/elevation_cache # Mount elevation cache directory individually + #- ./config:/home/ors/config # Mount configuration directory individually + #- ./logs:/home/ors/logs # Mount logs directory individually + #- ./files:/home/ors/files # Mount files directory individually environment: - - BUILD_GRAPHS=False # Forces the container to rebuild the graphs, e.g. when PBF is changed - - "JAVA_OPTS=-Djava.awt.headless=true -server -XX:TargetSurvivorRatio=75 -XX:SurvivorRatio=64 -XX:MaxTenuringThreshold=3 -XX:+UseG1GC -XX:+ScavengeBeforeFullGC -XX:ParallelGCThreads=4 -Xms1g -Xmx2g" - - "CATALINA_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9001 -Dcom.sun.management.jmxremote.rmi.port=9001 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost" - - ORS_CONFIG=/home/ors/ors-conf/ors-config.json \ No newline at end of file + REBUILD_GRAPHS: False # Set to True to rebuild graphs on container start. + CONTAINER_LOG_LEVEL: INFO # Log level for the container. Possible values: DEBUG, INFO, WARNING, ERROR, CRITICAL + # If you don't want the default ors-config.yml you can specify a custom file name, that should match the file in + # your 'config' volume mount. + #ORS_CONFIG_LOCATION: /home/ors/config/my-ors-config.yml # Location of your ORS configuration file in the docker container + + # ------------------ JAVA OPTS ------------------ # + # Configure the memory settings for JAVA or pass additional opts + # Fore more available ENV properties see Prepare CATALINA_OPTS and JAVA_OPTS + # in https://github.com/GIScience/openrouteservice/blob/main/docker-entrypoint.sh + XMS: 1g # start RAM assigned to java + XMX: 2g # max RAM assigned to java. Rule of Thumb: * * 2 + # Example: 1.5 GB pbf size, two profiles (car and foot-walking) + # -> 1.5 * 2 * 2 = 6. Set xmx to be AT LEAST `-Xmx6g` + ADDITIONAL_JAVA_OPTS: "" # further options you want to pass to the java command + + # ----------------- Properties configuration ------------------- # + # Configure your whole container with only property ENVs. + # These can be set alternatively or additionally to the yml configuration file. + # Note, that any values set will override the corresponding values from the yml configuration file. + # See the ors-config.env file for more options. + # To have a configuration file-less container, uncomment at least the following properties. + # The values are examples and provide the default configuration. + #ors.engine.source_file: /home/ors/files/example-heidelberg.osm.gz + #ors.engine.graphs_root_path: /home/ors/graphs + #ors.engine.elevation.cache_path: /home/ors/elevation_cache + #ors.engine.profiles.car.enabled: true + + # ----------------- ENV file configuration ------------------- # + # Too many variables for your 'environment:' section? + # Use an env_file with the ENV properties instead and define everything in there: + # Values will be overwritten if set in the 'environment' section. + #env_file: ors-config.env + + # ----------------- Healthcheck configuration ------------------- # + # The healthcheck is disabled by default. Uncomment the following lines to enable it. + # The healthcheck allows you to monitor the status of the ORS application. + # Be careful with long graph builds, as the healthcheck will fail and show 'unhealthy' during this time. + # This is especially useful if you run your ORS container in a production environment. + #healthcheck: + # test: wget --no-verbose --tries=1 --spider http://localhost:8082/ors/v2/health || exit 1 + # start_period: 1m + # interval: 10s + # timeout: 2s + # retries: 3 + # disable: false + +# ----------------- Docker Volumes configuration ------------------- # +# Define the Docker managed volumes for the ORS application. For more info on Docker Volumes see https://docs.docker.com/compose/compose-file/07-volumes/ +# Volumes are used to persist the data and configuration of the ORS application. +# If you want to use volumes, uncomment the following lines and remove the ./ prefix from the volume paths in 'services.ors-app.volumes'. +#volumes: +# graphs: +# elevation_cache: +# config: +# logs: +# files: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 7c50aef244..f74fb5397b 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,61 +1,364 @@ #!/usr/bin/env bash -echo "Running container as user $(whoami) with id $(id -u)" +######################## +# Set Helper functions # +######################## +# Log level functions +CONTAINER_LOG_LEVEL=${CONTAINER_LOG_LEVEL:-"INFO"} +# Success message in green. Always printed +function success() { + echo -e "\e[32m✓ $1\e[0m" + return 0 +} +# Critical message in bold red and exit. Always printed +function critical() { + echo -e "\e[1;31m $1\e[0m" + exit 1 +} +# Error message in red. +function error() { + echo -e "\e[31m✗ $1\e[0m" + return 0 +} +# Warning message in yellow +function warning() { + if [ "${container_log_level_int}" -le 30 ]; then + echo -e "\e[33m⚠ $1\e[0m" + fi + return 0 +} +# Info message in blue +function info() { + if [ "${container_log_level_int}" -le 20 ]; then + echo -e "\e[34mⓘ $1\e[0m" + fi + return 0 +} +# Debug message in cyan +function debug() { + if [ "${container_log_level_int}" -le 10 ]; then + echo -e "\e[36m▢ $1\e[0m" + fi + return 0 +} +function set_log_level() { + case ${CONTAINER_LOG_LEVEL} in + "DEBUG") + container_log_level_int=10 + ;; + "INFO") + container_log_level_int=20 + ;; + "WARN") + container_log_level_int=30 + ;; + "ERROR") + container_log_level_int=40 + ;; + "CRITICAL") + container_log_level_int=50 + ;; + *) + debug "No matching log level found: ${CONTAINER_LOG_LEVEL}." + debug "Defaulting to INFO." + CONTAINER_LOG_LEVEL="INFO" + container_log_level_int=20 + ;; + esac + success "CONTAINER_LOG_LEVEL: ${CONTAINER_LOG_LEVEL}. Set CONTAINER_LOG_LEVEL=DEBUG for more details." +} + +update_file() { + local target_file_path="$1" + local original_file_path="$2" + # Default to false + local print_migration_info_on_update="${3:-false}" + + if [ ! -f "${target_file_path}" ] || ! cmp -s "${original_file_path}" "${target_file_path}"; then + success "Update the file ${target_file_path} with ${original_file_path}" + cp -f "${original_file_path}" "${target_file_path}" || warning "Could not copy ${original_file_path} to ${target_file_path}" + if [ "${print_migration_info_on_update}" = "true" ]; then + print_migration_info="true" + fi + else + success "The file ${target_file_path} is up to date" + fi +} + +extract_config_info() { + local config_location="$1" + local config_variable="$2" + local config_value="" + if [[ "${config_location}" = *.yml ]]; then + config_value=$(yq -r "${config_variable}" "${config_location}") + elif [[ "${config_location}" = *.json ]]; then + config_value=$(jq -r "${config_variable}" "${config_location}") + fi + # Validate the config value + if [ -z "${config_value}" ] || [ "${config_value}" = null ]; then + config_value="" + fi + # Return the value + echo "${config_value}" +} + +echo "#################" +echo "# Container ENV #" +echo "#################" +# Validate the log level +set_log_level + +# Set the jar file location +jar_file=/ors.jar +BUILD_GRAPHS=${BUILD_GRAPHS:-"false"} +REBUILD_GRAPHS=${REBUILD_GRAPHS:-"false"} +# If BUILD_GRAPHS is set to true, we need to set ors_rebuild_graphs to true and print an info about migration to REBUILD_GRAPHS +if [ "${BUILD_GRAPHS}" = "true" ]; then + ors_rebuild_graphs="true" + warning "BUILD_GRAPHS is deprecated and will be removed in the future." + warning "Please use REBUILD_GRAPHS instead." +elif [ "${REBUILD_GRAPHS}" = "true" ]; then + ors_rebuild_graphs="true" +else + ors_rebuild_graphs="false" +fi + +# Parse the ors.* properties +env | while read -r line; do + debug "${line}" +done +info "Any config file settings can be overwritten by environment variables." +info "Use 'CONTAINER_LOG_LEVEL=DEBUG' to see the full list of active environment variables for this container." + +echo "###########################" +echo "# Container sanity checks #" +echo "###########################" +info "Running container as user $(whoami) with id $(id -u) and group $(id -g)" +if [[ $(id -u) -eq 0 ]] || [[ $(id -g) -eq 0 ]] ; then + debug "User and group are set to root with id 0 and group 0." +elif [[ $(id -u) -eq 1000 ]] || [[ $(id -g) -eq 1000 ]] ; then + debug "User and group are set to 1000 and group 1000." +else + # Test if the user tampered with the user and group settings + warning "Running container as user '$(whoami)' with id $(id -u) and group $(id -g)" + warning "Changing these values is only recommended if you're an advanced docker user and can handle file permission issues yourself." + warning "Consider leaving the user and group options as root with 0:0 or 1000:1000 or avoid that setting completely." + warning "If you need to change the user and group, make sure to rebuild the docker image with the appropriate UID,GID build args." +fi if [[ -d /ors-core ]] || [[ -d /ors-conf ]]; then - echo "You're mounting old paths. Remove them and migrate to the new docker setup: https://giscience.github.io/openrouteservice/run-instance/installation/running-with-docker" - echo "Exit setup due to old folders /ors-core or /ors-conf being mounted" - sleep 5 - exit 1 + warning "Found remnants of old docker setup." + warning "The ors-core and ors-conf folders are not used by default with the new docker setup." + warning "Continuing with the new docker setup." +fi + +# Fail if ORS_HOME env var is not set or if it is empty or set to / +if [ -z "${ORS_HOME}" ] || [ "${ORS_HOME}" = "/" ]; then + critical "ORS_HOME is not set or empty or set to /. This is not allowed. Exiting." +fi + +mkdir -p "${ORS_HOME}" || critical "Could not create ${ORS_HOME}" + +# Make sure ORS_HOME is a directory +if [ ! -d "${ORS_HOME}" ]; then + critical "ORS_HOME: ${ORS_HOME} doesn't exist. Exiting." +elif [ ! -w "${ORS_HOME}" ]; then + error "ORS_HOME: ${ORS_HOME} is not writable." + error "Make sure the file permission of ${ORS_HOME} in your volume mount are set to $(id -u):$(id -g)." + error "Under linux the command for a volume would be: sudo chown -R $(id -u):$(id -g) /path/to/ors/volume" + critical "Exiting." +fi + +success "ORS_HOME: ${ORS_HOME} exists and is writable." + +mkdir -p "${ORS_HOME}"/{files,logs,graphs,elevation_cache,config} || warning "Could not create the default folders in ${ORS_HOME}: files, logs, graphs, elevation_cache, config" +debug "Populated ORS_HOME=${ORS_HOME} with the default folders: files, logs, graphs, elevation_cache, config" + +# Check if the original jar file exists +if [ ! -f "${jar_file}" ]; then + critical "Jar file not found. This shouldn't happen. Exiting." fi -ors_base=${1} -catalina_base=${ors_base}/tomcat -graphs=${ors_base}/ors-core/data/graphs +# get ors.engine.graphs_root_path=. Dot notations in bash are not allowed, so we need to use awk to parse it. +ors_engine_graphs_root_path=$(env | grep "^ors\.engine\.graphs_root_path=" | awk -F '=' '{print $2}') +# get ors.engine.elevation.cache_path +ors_engine_elevation_cache_path=$(env | grep "^ors\.engine\.elevation\.cache_path=" | awk -F '=' '{print $2}') +# get ors.engine.source_file +ors_engine_source_file=$(env | grep "^ors\.engine\.source_file=" | awk -F '=' '{print $2}') -echo "ORS Path: ${ors_base}" -echo "Catalina Path: ${catalina_base}" +# Check that ors_engine_graphs_root_path is not empty and not set to / +if [ -n "${ors_engine_graphs_root_path}" ] && [ "${ors_engine_graphs_root_path}" = "/" ]; then + critical "ors.engine.graphs_root_path is set to /. This is not allowed. Exiting." +else + debug "ors.engine.graphs_root_path=${ors_engine_graphs_root_path} is set and not empty and not set to /" +fi +# Check that ors_engine_elevation_cache_path is not empty and not set to / +if [ -n "${ors_engine_elevation_cache_path}" ] && [ "${ors_engine_elevation_cache_path}" = "/" ]; then + critical "ors.engine.elevation.cache_path is set to /. This is not allowed. Exiting." +else + debug "ors.engine.elevation.cache_path=${ors_engine_elevation_cache_path} is set and not empty and not set to /" +fi -if [ -z "${CATALINA_OPTS}" ]; then - export CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9001 -Dcom.sun.management.jmxremote.rmi.port=9001 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost" +# Update the example-ors-config.env and example-ors-config.yml files if they don't exist or have changed +update_file "${ORS_HOME}/config/example-ors-config.env" "/example-ors-config.env" "true" +update_file "${ORS_HOME}/config/example-ors-config.yml" "/example-ors-config.yml" "true" + +# The config situation is difficult due to the recent ors versions. +# To ensure a smooth transition, we need to check if the user is using a .json file or a .yml file. +# If neither is set, we need to print a migration info and default to the example-ors-config.env file. +# get ors_config_location +ors_config_location=${ORS_CONFIG_LOCATION:-""} +# Unset the ORS_CONFIG_LOCATION to not interfere with the spring-boot application +unset ORS_CONFIG_LOCATION +# Check if ors_config_location is a .json file and exists +if [[ "${ors_config_location}" = *.yml ]] && [[ -f "${ors_config_location}" ]]; then + success "Using yml config from ENV: ${ors_config_location}" +elif [[ "${ors_config_location}" = *.json ]] && [[ -f "${ors_config_location}" ]]; then + success "Using json config from ENV: ${ors_config_location}" + # Print the above warning message in individual warning calls + warning ".json configurations are deprecated and will be removed in the future." + print_migration_info="true" +elif [[ -f ${ORS_HOME}/config/ors-config.yml ]]; then + success "Using the existing ors-config.yml from: ${ORS_HOME}/config/ors-config.yml" + ors_config_location="${ORS_HOME}/config/ors-config.yml" +else + warning "No config file found. Copying /example-ors-config.yml to ${ORS_HOME}/config/ors-config.yml" + warning "To adjust your config edit ors-config.yml in your 'config' docker volume or use the environment variable configuration." + update_file "${ORS_HOME}/config/ors-config.yml" "/example-ors-config.yml" + ors_config_location="${ORS_HOME}/config/ors-config.yml" fi -if [ -z "${JAVA_OPTS}" ]; then - export JAVA_OPTS="-Djava.awt.headless=true -server -XX:TargetSurvivorRatio=75 -XX:SurvivorRatio=64 -XX:MaxTenuringThreshold=3 -XX:+UseG1GC -XX:+ScavengeBeforeFullGC -XX:ParallelGCThreads=4 -Xms1g -Xmx2g" +# Get relevant configuration information from the .yml or .json file +if [[ -z "${ors_engine_graphs_root_path}" ]]; then + if [[ "${config_location}" = *.yml ]]; then + ors_engine_graphs_root_path=$(extract_config_info "${ors_config_location}" '.ors.engine.graphs_root_path') + elif [[ "${config_location}" = *.json ]]; then + ors_engine_graphs_root_path=$(extract_config_info "${ors_config_location}" '.ors.services.routing.profiles.default_params.graphs_root_path') + fi fi -{ - echo "CATALINA_BASE=\"${catalina_base}\"" - echo "CATALINA_HOME=\"${catalina_base}\"" - echo "CATALINA_PID=\"${catalina_base}/temp/tomcat.pid\"" - echo "CATALINA_OPTS=\"${CATALINA_OPTS}\"" - echo "JAVA_OPTS=\"${JAVA_OPTS}\"" -} >"${catalina_base}"/bin/setenv.sh +if [[ -z "${ors_engine_source_file}" ]]; then + if [[ "${ors_config_location}" = *.yml ]]; then + ors_engine_source_file=$(extract_config_info "${ors_config_location}" '.ors.engine.source_file') + elif [[ "${ors_config_location}" = *.json ]]; then + ors_engine_source_file=$(extract_config_info "${ors_config_location}" '.ors.services.routing.sources[0]') + fi +fi -if [ "${BUILD_GRAPHS}" = "True" ]; then - rm -rf "${graphs:?}"/* +if [ -n "${ors_engine_graphs_root_path}" ]; then + success "Using graphs folder ${ors_engine_graphs_root_path}" +else + info "Default to graphs folder: ${ORS_HOME}/graphs" + ors_engine_graphs_root_path="${ORS_HOME}/graphs" fi -echo "### openrouteservice configuration ###" -# Always overwrite the example config in case another one is present -cp -f "${ors_base}/tmp/ors-config.yml" "${ors_base}/ors-conf/ors-config-example.yml" -# Check for old .json configs -JSON_FILES=$(ls -d -- "${ors_base}/ors-conf/"*.json 2>/dev/null) -if [ -n "$JSON_FILES" ]; then - echo "Old .json config found. They're deprecated and will be replaced in ORS version 8." - echo "Please migrate to the new .yml example." +if [ -n "${ors_engine_source_file}" ]; then + debug "OSM source file set to ${ors_engine_source_file}" + # Check if it is the example file in root or the home folder + if [[ "${ors_engine_source_file}" = "${ORS_HOME}/files/example-heidelberg.osm.gz" ]]; then + info "Default to example osm source file: \"${ors_engine_source_file}\"" + fi fi -# No config found. Use the base config -if [ ! -f "${ors_base}/ors-conf/ors-config.yml" ]; then - echo "Copy ors-config.yml" - cp -f "${ors_base}/tmp/ors-config.yml" "${ors_base}/ors-conf/ors-config.yml" + +info "Any ENV variables will have precedence over configuration variables from config files." +success "All checks passed. For details set CONTAINER_LOG_LEVEL=DEBUG." + +echo "#####################################" +echo "# Container file system preparation #" +echo "#####################################" +# Check if uid or gid is different from 1000 +chown -R "$(whoami)" "${ORS_HOME}"; debug "Changed ownership of ${ORS_HOME} to $(whoami)" || warning "Could not change ownership of ${ORS_HOME} to $(whoami)" + + +update_file "${ORS_HOME}/files/example-heidelberg.osm.gz" "/heidelberg.osm.gz" + +# Remove existing graphs if BUILD_GRAPHS is set to true +if [ "${ors_rebuild_graphs}" = "true" ]; then + # Warn if ors.engine.graphs_root_path is not set or empty + if [ -z "${ors_engine_graphs_root_path}" ]; then + warning "graphs_root_path is not set or could not be found. Skipping cleanup." + elif [ -d "${ors_engine_graphs_root_path}" ]; then + # Check the ors.engine.graphs_root_path folder exists + rm -rf "${ors_engine_graphs_root_path:?}"/* || warning "Could not remove ${ors_engine_graphs_root_path}" + success "Removed graphs at ${ors_engine_graphs_root_path}/*." + else + debug "${ors_engine_graphs_root_path} does not exist (yet). Skipping cleanup." + fi + # Create the graphs folder again + mkdir -p "${ors_engine_graphs_root_path}" || warning "Could not populate graph folder at ${ors_engine_graphs_root_path}" fi -if [ ! -f "${ors_base}/ors-core/data/osm_file.pbf" ]; then - echo "Copy osm_file.pbf" - cp -f "${ors_base}/tmp/osm_file.pbf" "${ors_base}/ors-core/data/osm_file.pbf" +success "Container file system preparation complete. For details set CONTAINER_LOG_LEVEL=DEBUG." + +echo "#######################################" +echo "# Prepare CATALINA_OPTS and JAVA_OPTS #" +echo "#######################################" +# Let the user define every parameter via env vars if not, default to the values below +management_jmxremote_port=${MANAGEMENT_JMXREMOTE_PORT:-9001} +management_jmxremote_rmi_port=${MANAGEMENT_JMXREMOTE_RMI_PORT:-9001} +management_jmxremote_authenticate=${MANAGEMENT_JMXREMOTE_AUTHENTICATE:-false} +management_jmxremote_ssl=${MANAGEMENT_JMXREMOTE_SSL:-false} +java_rmi_server_hostname=${JAVA_RMI_SERVER_HOSTNAME:-localhost} +additional_catalina_opts=${ADDITIONAL_CATALINA_OPTS:-""} +# Let the user define every parameter via env vars if not, default to the values below +target_survivor_ratio=${TARGET_SURVIVOR_RATIO:-75} +survivor_ratio=${SURVIVOR_RATIO:-64} +max_tenuring_threshold=${MAX_TENURING_THRESHOLD:-3} +parallel_gc_threads=${PARALLEL_GC_THREADS:-4} + +xms=${XMS:-1g} +xmx=${XMX:-2g} +additional_java_opts=${ADDITIONAL_JAVA_OPTS:-""} + +CATALINA_OPTS="-Dcom.sun.management.jmxremote \ +-Dcom.sun.management.jmxremote.port=${management_jmxremote_port} \ +-Dcom.sun.management.jmxremote.rmi.port=${management_jmxremote_rmi_port} \ +-Dcom.sun.management.jmxremote.authenticate=${management_jmxremote_authenticate} \ +-Dcom.sun.management.jmxremote.ssl=${management_jmxremote_ssl} \ +-Djava.rmi.server.hostname=${java_rmi_server_hostname} \ +${additional_catalina_opts}" +debug "CATALINA_OPTS: ${CATALINA_OPTS}" + +JAVA_OPTS="-Djava.awt.headless=true \ +-server -XX:TargetSurvivorRatio=${target_survivor_ratio} \ +-XX:SurvivorRatio=${survivor_ratio} \ +-XX:MaxTenuringThreshold=${max_tenuring_threshold} \ +-XX:+UseG1GC \ +-XX:+ScavengeBeforeFullGC \ +-XX:ParallelGCThreads=${parallel_gc_threads} \ +-Xms${xms} \ +-Xmx${xmx} \ +${additional_java_opts}" +debug "JAVA_OPTS: ${JAVA_OPTS}" +success "CATALINA_OPTS and JAVA_OPTS ready. For details set CONTAINER_LOG_LEVEL=DEBUG." + +# Print the migration info if print_migration_info is set to true but not if PRINT_MIGRATION_INFO is set to False +if [ "${print_migration_info}" = "true" ]; then + info "##########################################" + info "# Config migration and usage information #" + info "##########################################" + info ">>> Migration information <<<" + info "Find detailed information for migrating to ORS version 8 at: "# TODO + info ">>> Config migration <<<" + info "Configuring ors with a .json config is deprecated and will be removed in the future." + info "You have the following options to configure ORS:" + info "Method 1 yml config:" + info "> docker cp ors-container-name:${ORS_HOME}/config/example-ors-config.yml ./ors-config.yml" + info "> docker run --name example-ors-instance-conf-file -e ORS_CONFIG_LOCATION=${ORS_HOME}/config/ors-config.yml -v \$(pwd)/ors-config.yml:${ORS_HOME}/config/ors-config.yml openrouteservice/openrouteservice:latest" + info "Method 2 environment variables:" + info "> docker cp ors-container-name:${ORS_HOME}/config/example-ors-config.env ./ors-config.env" + info "> docker run --name example-ors-instance-env-file --env-file ors-config.env openrouteservice/openrouteservice:latest" + info ">>> End of migration information <<<" fi -# so docker can stop the process gracefully -exec "${catalina_base}"/bin/catalina.sh run +echo "#####################" +echo "# ORS startup phase #" +echo "#####################" +# Start the jar with the given arguments and add the ORS_HOME env var +success "🙭 Ready to start the ORS application 🙭" +debug "Startup command: java ${JAVA_OPTS} ${CATALINA_OPTS} -jar ${jar_file}" +# Export ORS_CONFIG_LOCATION to the environment of child processes +export ORS_CONFIG_LOCATION=${ors_config_location} +# shellcheck disable=SC2086 # we need word splitting here +exec java ${JAVA_OPTS} ${CATALINA_OPTS} -jar "${jar_file}" "$@" diff --git a/docs/run-instance/running-with-docker.md b/docs/run-instance/running-with-docker.md index 99789fb740..87c70ff82d 100644 --- a/docs/run-instance/running-with-docker.md +++ b/docs/run-instance/running-with-docker.md @@ -1,19 +1,24 @@ # Running with Docker -If Docker is available on your system, openrouteservice can be run within a container using prebuilt images from [dockerhub](https://hub.docker.com/r/openrouteservice/openrouteservice) or by building your own image from our source files. +If Docker is available on your system, openrouteservice can be run within a container using prebuilt images +from [dockerhub](https://hub.docker.com/r/openrouteservice/openrouteservice) or by building your own image from the +source files. ## Prerequisites -* [Docker](https://docs.docker.com/get-docker/) should be installed on your system. +- [Docker](https://docs.docker.com/get-docker/) +- an OSM extract, e.g. from [Geofabrik](http://download.geofabrik.de) or for small areas directly export +from [osm.org](https://www.openstreetmap.org/export#map=15/49.4197/8.6893). -## Running prebuilt images +## Docker compose There are multiple ways with Docker to quickly have a running instance. +### Prebuilt image 1. Recommended: Run latest release version image using `docker compose` ```shell - # For latest release build + # For latest build wget https://raw.githubusercontent.com/GIScience/openrouteservice/main/docker-compose.yml docker compose up -d ``` @@ -31,9 +36,11 @@ There are multiple ways with Docker to quickly have a running instance. export ORS_TAG=nightly && docker compose up -d ``` -## Build image +## Build local image -To build your own image, you need to download the source code by following the instructions in chapter [Building from Source](/run-instance/building-from-source.md#download-source-code). You do not have to have Java or Maven installed on your system. +To build your own image, you need to download the source code by following the instructions in chapter +[Building from Source](/run-instance/building-from-source.md#download-source-code). +You do not have to have Java or Maven installed on your system. After downloading the source, you can build your Docker image by running the following command in the source directory: @@ -50,7 +57,7 @@ export ORS_TAG=local && docker compose up -d ::: details Alternative: modify docker compose to build image -After downloading the code, open the file `docker-compose.yml`, remove line 8 and uncomment lines 11-14. +After downloading the code, open the file `docker-compose.yml`, and apply the following changes: ```yaml version: '2.4' @@ -58,10 +65,10 @@ services: ors-app: container_name: ors-app ports: - - "8080:8080" + - "8080:8082" - "9001:9001" image: openrouteservice/openrouteservice:nightly // [!code --] - # For versioned images see https://giscience.github.io/openrouteservice/run-instance/installation/running-with-docker + # For versioned images see https://giscience.github.io/openrouteservice/run-instance/running-with-docker user: "${UID:-0}:${GID:-0}" # build: // [!code --] # context: ./ // [!code --] @@ -100,14 +107,14 @@ command. To use a different version of openrouteservice, change the tag (after t mkdir -p docker/conf docker/elevation_cache docker/graphs docker/logs/ors docker/logs/tomcat docker run -dt -u "${UID}:${GID}" \ --name ors-app \ - -p 8080:8080 \ + -p 8080:8082 \ -v $PWD/docker/graphs:/home/ors/ors-core/data/graphs \ -v $PWD/docker/elevation_cache:/home/ors/ors-core/data/elevation_cache \ -v $PWD/docker/logs/ors:/home/ors/ors-core/logs/ors \ -v $PWD/docker/logs/tomcat:/home/ors/tomcat/logs \ -v $PWD/docker/conf:/home/ors/ors-conf \ -v $PWD/docker/data:/home/ors/ors-core/data \ - #-e "BUILD_GRAPHS=True" \ + #-e "REBUILD_GRAPHS=True" \ -e "JAVA_OPTS=-Djava.awt.headless=true -server -XX:TargetSurvivorRatio=75 -XX:SurvivorRatio=64 -XX:MaxTenuringThreshold=3 -XX:+UseG1GC -XX:+ScavengeBeforeFullGC -XX:ParallelGCThreads=4 -Xms1g -Xmx2g" \ -e "CATALINA_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9001 -Dcom.sun.management.jmxremote.rmi.port=9001 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost" \ openrouteservice/openrouteservice:latest @@ -155,7 +162,7 @@ the use of old format JSON files placed at `./docker/conf/ors-config.json`. All will override settings in the proper YAML format. If you are making changes to anything relating to the OSM data or the settings that change how graphs are built, you -need to delete the folders in `graphs` or set the environment variable `BUILD_GRAPHS=True` (see comment in Dockerfile or +need to delete the folders in `graphs` or set the environment variable `REBUILD_GRAPHS=True` (see comment in Dockerfile or examples above). This makes it so that the graphs are built again with the new data/settings. ### Different OSM file @@ -164,7 +171,7 @@ To change the OSM data that is used, you can either overwrite the `docker/data/o mount of `/home/ors/ors-core/data` to a directory containing a file `osm_file.pbf`, or volume mount something like `/YOUR/PATH/TO/ANOTHER/OSM_FILE.pbf:/home/ors/ors-core/data/osm_file.pbf`. -Make sure to set the environment variable `BUILD_GRAPHS=True` or empty the `docker/graphs/` directory before restarting +Make sure to set the environment variable `REBUILD_GRAPHS=True` or empty the `docker/graphs/` directory before restarting the container. If you are building the Docker image locally, you can also point the build argument `OSM_FILE` to your desired OSM file @@ -212,7 +219,7 @@ examples. ### Environment variables -- `BUILD_GRAPHS`: Forces ORS to rebuild the routing graph(s) when set to `True`. Useful when another PBF is specified in +- `REBUILD_GRAPHS`: Forces ORS to rebuild the routing graph(s) when set to `True`. Useful when another PBF is specified in the Docker volume mapping to `/home/ors/ors-core/data/osm_file.pbf` - `JAVA_OPTS`: Custom Java runtime options, such as `-Xms` or `-Xmx` - `CATALINA_OPTS`: Custom Catalina options @@ -243,5 +250,5 @@ container. The new graphs will be reloaded into memory (the amount of time neede graphs and the type of hard drive) and then ready to use for routing. The downtime from reloading already built graphs is normally far less than the time needed to build the graphs. A thing to note though is that you should ensure that the config files and the amount of RAM allocated (as described earlier) is the same on both the builder and the request -server else the newly built graphs may not load. **Also, ensure that `BUILD_GRAPHS` parameter in the `docker-compose` +server else the newly built graphs may not load. **Also, ensure that `REBUILD_GRAPHS` parameter in the `docker-compose` file used by the request serving container is set to false else it will try to build the graphs for itself!** diff --git a/ors-api/src/main/resources/application.yml b/ors-api/src/main/resources/application.yml index e1ac7a8f44..831d261efd 100644 --- a/ors-api/src/main/resources/application.yml +++ b/ors-api/src/main/resources/application.yml @@ -1,6 +1,6 @@ ##### openrouteservice settings file ##### # This file contains parameters for openrouteservice. -# For a full list of possible parameters see https://giscience.github.io/openrouteservice/ +# For a full list of possible parameters see https://giscience.github.io/openrouteservice/run-instance/configuration/ ##### General server settings ##### server: diff --git a/ors-config.env b/ors-config.env new file mode 100644 index 0000000000..df38d45b93 --- /dev/null +++ b/ors-config.env @@ -0,0 +1,214 @@ +#server.port=8082 +#server.error.whitelabel.enabled=false +#server.servlet.context-path=/ors +#spring.profiles.active=default +#spring.mvc.servlet.path=/ +#springdoc.swagger-ui.enabled=true +#springdoc.swagger-ui.path=/swagger-ui +#springdoc.swagger-ui.tryItOutEnabled=true +#springdoc.swagger-ui.filter=false +#springdoc.swagger-ui.syntaxHighlight.activated=true +#springdoc.swagger-ui.showExtensions=true +#springdoc.api-docs.path=/v2/api-docs +#springdoc.api-docs.version=OPENAPI_3_0 +#springdoc.packages-to-scan=org.heigit.ors +#springdoc.pathsToMatch=/v2/** +#logging.file.name=./logs/ors.log +#logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %highlight{%-7p} %style{%50t}{Cyan} %style{[ %-40.40c{1.} ]}{Bright Cyan} %m%n +#logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss} %p [%-40.40c{1.}] - %m%n +#logging.level.root=WARN +#logging.level.org.heigit=INFO +#ors.cors.allowed_origins=* +#ors.cors.allowed_headers=Content-Type, X-Requested-With, accept, Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Authorization +#ors.cors.preflight_max_age=600 +#ors.messages= +#ors.endpoints.routing.enabled=true +#ors.endpoints.routing.attribution=openrouteservice.org, OpenStreetMap contributors, tmc - BASt +#ors.endpoints.routing.gpx_name=ORSRouting +#ors.endpoints.routing.gpx_description=This is a directions instructions file as GPX, generated from openrouteservice +#ors.endpoints.routing.gpx_base_url=https://openrouteservice.org/ +#ors.endpoints.routing.gpx_support_mail=support@openrouteservice.org +#ors.endpoints.routing.gpx_author=openrouteservice +#ors.endpoints.routing.gpx_content_licence=LGPL 3.0 +#ors.endpoints.routing.maximum_avoid_polygon_area=200000000 +#ors.endpoints.routing.maximum_avoid_polygon_extent=20000 +#ors.endpoints.routing.maximum_alternative_routes=3 +#ors.endpoints.matrix.enabled=true +#ors.endpoints.matrix.attribution=openrouteservice.org, OpenStreetMap contributors +#ors.endpoints.matrix.maximum_routes=2500 +#ors.endpoints.matrix.maximum_routes_flexible=25 +#ors.endpoints.matrix.maximum_visited_nodes=100000 +#ors.endpoints.matrix.maximum_search_radius=2000 +#ors.endpoints.matrix.u_turn_costs=-1 +#ors.endpoints.isochrones.enabled=true +#ors.endpoints.isochrones.attribution=openrouteservice.org, OpenStreetMap contributors +#ors.endpoints.isochrones.maximum_locations=2 +#ors.endpoints.isochrones.maximum_intervals=1 +#ors.endpoints.isochrones.allow_compute_area=true +#ors.endpoints.isochrones.maximum_range_distance_default=50000 +#ors.endpoints.isochrones.maximum_range_distance.0.profiles=driving-car, driving-hgv +#ors.endpoints.isochrones.maximum_range_distance.0.value=100000 +#ors.endpoints.isochrones.maximum_range_time_default=18000 +#ors.endpoints.isochrones.maximum_range_time.0.profiles=driving-car, driving-hgv +#ors.endpoints.isochrones.maximum_range_time.0.value=3600 +#ors.endpoints.isochrones.fastisochrones.maximum_range_distance_default=50000 +#ors.endpoints.isochrones.fastisochrones.maximum_range_distance.0.profiles=driving-car, driving-hgv +#ors.endpoints.isochrones.fastisochrones.maximum_range_distance.0.value=500000 +#ors.endpoints.isochrones.fastisochrones.maximum_range_time_default=18000 +#ors.endpoints.isochrones.fastisochrones.maximum_range_time.0.profiles=driving-car, driving-hgv +#ors.endpoints.isochrones.fastisochrones.maximum_range_time.0.value=10800 +#ors.endpoints.Snap.enabled=true +#ors.endpoints.Snap.attribution=openrouteservice.org, OpenStreetMap contributors +ors.engine.source_file=ors-api/src/test/files/heidelberg.osm.gz +#ors.engine.init_threads=1 +#ors.engine.preparation_mode=false +#ors.engine.graphs_root_path=./graphs +#ors.engine.graphs_data_access=RAM_STORE +#ors.engine.elevation.preprocessed=false +#ors.engine.elevation.data_access=MMAP +#ors.engine.elevation.cache_clear=false +#ors.engine.elevation.provider=multi +#ors.engine.elevation.cache_path=./elevation_cache +#ors.engine.profile_default.enabled=false +#ors.engine.profile_default.elevation=false +#ors.engine.profile_default.elevation_smoothing=false +#ors.engine.profile_default.encoder_flags_size=8 +#ors.engine.profile_default.instructions=true +#ors.engine.profile_default.optimize=false +#ors.engine.profile_default.traffic=false +#ors.engine.profile_default.maximum_distance=100000 +#ors.engine.profile_default.maximum_distance_dynamic_weights=100000 +#ors.engine.profile_default.maximum_distance_avoid_areas=100000 +#ors.engine.profile_default.maximum_waypoints=50 +#ors.engine.profile_default.maximum_snapping_radius=400 +#ors.engine.profile_default.maximum_distance_alternative_routes=100000 +#ors.engine.profile_default.maximum_distance_round_trip_routes=100000 +#ors.engine.profile_default.maximum_speed_lower_bound=80 +#ors.engine.profile_default.maximum_visited_nodes=1000000 +#ors.engine.profile_default.location_index_resolution=500 +#ors.engine.profile_default.location_index_search_iterations=4 +#ors.engine.profile_default.force_turn_costs=false +#ors.engine.profile_default.interpolate_bridges_and_tunnels=true +#ors.engine.profile_default.preparation.min_network_size=200 +#ors.engine.profile_default.preparation.methods.lm.enabled=true +#ors.engine.profile_default.preparation.methods.lm.threads=1 +#ors.engine.profile_default.preparation.methods.lm.weightings=recommended,shortest +#ors.engine.profile_default.preparation.methods.lm.landmarks=16 +#ors.engine.profile_default.execution.methods.lm.active_landmarks=8 +ors.engine.profiles.car.enabled=true +#ors.engine.profiles.car.profile=driving-car +#ors.engine.profiles.car.elevation=true +#ors.engine.profiles.car.encoder_options.turn_costs=true +#ors.engine.profiles.car.encoder_options.block_fords=false +#ors.engine.profiles.car.encoder_options.use_acceleration=true +#ors.engine.profiles.car.preparation.min_network_size=200 +#ors.engine.profiles.car.preparation.methods.ch.enabled=true +#ors.engine.profiles.car.preparation.methods.ch.threads=1 +#ors.engine.profiles.car.preparation.methods.ch.weightings=fastest +#ors.engine.profiles.car.preparation.methods.lm.enabled=false +#ors.engine.profiles.car.preparation.methods.lm.threads=1 +#ors.engine.profiles.car.preparation.methods.lm.weightings=fastest,shortest +#ors.engine.profiles.car.preparation.methods.lm.landmarks=16 +#ors.engine.profiles.car.preparation.methods.core.enabled=true +#ors.engine.profiles.car.preparation.methods.core.threads=1 +#ors.engine.profiles.car.preparation.methods.core.weightings=fastest,shortest +#ors.engine.profiles.car.preparation.methods.core.landmarks=64 +#ors.engine.profiles.car.preparation.methods.core.lmsets=highways;allow_all +#ors.engine.profiles.car.execution.methods.lm.active_landmarks=6 +#ors.engine.profiles.car.execution.methods.core.active_landmarks=6 +#ors.engine.profiles.car.ext_storages.WayCategory= +#ors.engine.profiles.car.ext_storages.HeavyVehicle= +#ors.engine.profiles.car.ext_storages.WaySurfaceType= +#ors.engine.profiles.car.ext_storages.RoadAccessRestrictions.use_for_warnings=true +#ors.engine.profiles.hgv.enabled=false +#ors.engine.profiles.hgv.profile=driving-hgv +#ors.engine.profiles.hgv.encoder_flags_size=8 +#ors.engine.profiles.hgv.encoder_options.turn_costs=true +#ors.engine.profiles.hgv.encoder_options.block_fords=false +#ors.engine.profiles.hgv.encoder_options.use_acceleration=true +#ors.engine.profiles.hgv.maximum_distance=100000 +#ors.engine.profiles.hgv.elevation=true +#ors.engine.profiles.hgv.preparation.min_network_size=200 +#ors.engine.profiles.hgv.preparation.methods.ch.enabled=true +#ors.engine.profiles.hgv.preparation.methods.ch.threads=1 +#ors.engine.profiles.hgv.preparation.methods.ch.weightings=recommended +#ors.engine.profiles.hgv.preparation.methods.core.enabled=true +#ors.engine.profiles.hgv.preparation.methods.core.threads=1 +#ors.engine.profiles.hgv.preparation.methods.core.weightings=recommended,shortest +#ors.engine.profiles.hgv.preparation.methods.core.landmarks=64 +#ors.engine.profiles.hgv.preparation.methods.core.lmsets=highways;allow_all +#ors.engine.profiles.hgv.execution.methods.core.active_landmarks=6 +#ors.engine.profiles.hgv.ext_storages.WayCategory= +#ors.engine.profiles.hgv.ext_storages.HeavyVehicle.restrictions=true +#ors.engine.profiles.hgv.ext_storages.WaySurfaceType= +#ors.engine.profiles.bike-regular.enabled=false +#ors.engine.profiles.bike-regular.profile=cycling-regular +#ors.engine.profiles.bike-regular.encoder_options.consider_elevation=true +#ors.engine.profiles.bike-regular.encoder_options.turn_costs=true +#ors.engine.profiles.bike-regular.encoder_options.block_fords=false +#ors.engine.profiles.bike-regular.elevation=true +#ors.engine.profiles.bike-regular.ext_storages.WayCategory= +#ors.engine.profiles.bike-regular.ext_storages.WaySurfaceType= +#ors.engine.profiles.bike-regular.ext_storages.HillIndex= +#ors.engine.profiles.bike-regular.ext_storages.TrailDifficulty= +#ors.engine.profiles.bike-mountain.enabled=false +#ors.engine.profiles.bike-mountain.profile=cycling-mountain +#ors.engine.profiles.bike-mountain.encoder_options.consider_elevation=true +#ors.engine.profiles.bike-mountain.encoder_options.turn_costs=true +#ors.engine.profiles.bike-mountain.encoder_options.block_fords=false +#ors.engine.profiles.bike-mountain.elevation=true +#ors.engine.profiles.bike-mountain.ext_storages.WayCategory= +#ors.engine.profiles.bike-mountain.ext_storages.WaySurfaceType= +#ors.engine.profiles.bike-mountain.ext_storages.HillIndex= +#ors.engine.profiles.bike-mountain.ext_storages.TrailDifficulty= +#ors.engine.profiles.bike-road.enabled=false +#ors.engine.profiles.bike-road.profile=cycling-road +#ors.engine.profiles.bike-road.encoder_options.consider_elevation=true +#ors.engine.profiles.bike-road.encoder_options.turn_costs=true +#ors.engine.profiles.bike-road.encoder_options.block_fords=false +#ors.engine.profiles.bike-road.elevation=true +#ors.engine.profiles.bike-road.ext_storages.WayCategory= +#ors.engine.profiles.bike-road.ext_storages.WaySurfaceType= +#ors.engine.profiles.bike-road.ext_storages.HillIndex= +#ors.engine.profiles.bike-road.ext_storages.TrailDifficulty= +#ors.engine.profiles.bike-electric.enabled=false +#ors.engine.profiles.bike-electric.profile=cycling-electric +#ors.engine.profiles.bike-electric.encoder_options.consider_elevation=true +#ors.engine.profiles.bike-electric.encoder_options.turn_costs=true +#ors.engine.profiles.bike-electric.encoder_options.block_fords=false +#ors.engine.profiles.bike-electric.elevation=true +#ors.engine.profiles.bike-electric.ext_storages.WayCategory= +#ors.engine.profiles.bike-electric.ext_storages.WaySurfaceType= +#ors.engine.profiles.bike-electric.ext_storages.HillIndex= +#ors.engine.profiles.bike-electric.ext_storages.TrailDifficulty= +#ors.engine.profiles.walking.enabled=false +#ors.engine.profiles.walking.profile=foot-walking +#ors.engine.profiles.walking.encoder_options.block_fords=false +#ors.engine.profiles.walking.elevation=true +#ors.engine.profiles.walking.ext_storages.WayCategory= +#ors.engine.profiles.walking.ext_storages.WaySurfaceType= +#ors.engine.profiles.walking.ext_storages.HillIndex= +#ors.engine.profiles.walking.ext_storages.TrailDifficulty= +#ors.engine.profiles.hiking.enabled=false +#ors.engine.profiles.hiking.profile=foot-hiking +#ors.engine.profiles.hiking.encoder_options.block_fords=false +#ors.engine.profiles.hiking.elevation=true +#ors.engine.profiles.hiking.ext_storages.WayCategory= +#ors.engine.profiles.hiking.ext_storages.WaySurfaceType= +#ors.engine.profiles.hiking.ext_storages.HillIndex= +#ors.engine.profiles.hiking.ext_storages.TrailDifficulty= +#ors.engine.profiles.wheelchair.enabled=false +#ors.engine.profiles.wheelchair.profile=wheelchair +#ors.engine.profiles.wheelchair.encoder_options.block_fords=true +#ors.engine.profiles.wheelchair.elevation=true +#ors.engine.profiles.wheelchair.maximum_snapping_radius=50 +#ors.engine.profiles.wheelchair.ext_storages.WayCategory= +#ors.engine.profiles.wheelchair.ext_storages.WaySurfaceType= +#ors.engine.profiles.wheelchair.ext_storages.Wheelchair.KerbsOnCrossings=true +#ors.engine.profiles.wheelchair.ext_storages.OsmId= +#ors.engine.profiles.public-transport.enabled=false +#ors.engine.profiles.public-transport.profile=public-transport +#ors.engine.profiles.public-transport.encoder_options.block_fords=false +#ors.engine.profiles.public-transport.elevation=true +#ors.engine.profiles.public-transport.maximum_visited_nodes=1000000 +#ors.engine.profiles.public-transport.gtfs_file=./src/test/files/vrn_gtfs_cut.zip diff --git a/ors-config.yml b/ors-config.yml index 996323fc12..8474bbb914 100644 --- a/ors-config.yml +++ b/ors-config.yml @@ -1,6 +1,6 @@ ##### openrouteservice settings file ##### # This file contains parameters for openrouteservice. -# For a full list of possible parameters see https://giscience.github.io/openrouteservice/ +# For a full list of possible parameters see https://giscience.github.io/openrouteservice/run-instance/configuration/ ##### General server settings ##### #server: @@ -8,17 +8,15 @@ # error: # whitelabel: # enabled: false - # Keep the context-path at / else the war file run with tomcat will have the context-path of /ors/v2 as well. +# # Keep the context-path at / else the war file run with tomcat will have the context-path of /ors/v2 as well. # servlet: # context-path: /ors - #spring: # profiles: # active: default # mvc: # servlet: # path: / - ##### Settings related to springdoc ##### #springdoc: # swagger-ui: @@ -34,23 +32,24 @@ # version: OPENAPI_3_0 # packages-to-scan: org.heigit.ors # pathsToMatch: /v2/** - ##### Logging settings ##### #logging: +# file: +# name: ./logs/ors.log +# pattern: +# console: "%d{yyyy-MM-dd HH:mm:ss} %highlight{%-7p} %style{%50t}{Cyan} %style{[ %-40.40c{1.} ]}{Bright Cyan} %m%n" +# file: "%d{yyyy-MM-dd HH:mm:ss} %p [%-40.40c{1.}] - %m%n" # level: # root: WARN # org.heigit: INFO - ##### openrouteservice specific settings ##### ors: # cors: # allowed_origins: "*" # allowed_headers: Content-Type, X-Requested-With, accept, Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Authorization # preflight_max_age: 600 - # messages: - - ##### ORS endpoints settings ##### +# ##### ORS endpoints settings ##### # endpoints: # routing: # enabled: true @@ -72,7 +71,7 @@ ors: # maximum_visited_nodes: 100000 # maximum_search_radius: 2000 # u_turn_costs: -1 -# isochrone: +# isochrones: # enabled: true # attribution: openrouteservice.org, OpenStreetMap contributors # maximum_locations: 2 @@ -98,12 +97,11 @@ ors: # Snap: # enabled: true # attribution: openrouteservice.org, OpenStreetMap contributors - - ##### ORS engine settings ##### +# ##### ORS engine settings ##### engine: + source_file: ors-api/src/test/files/heidelberg.osm.gz # init_threads: 1 # preparation_mode: false - source_file: ors-api/src/test/files/heidelberg.osm.gz # graphs_root_path: ./graphs # graphs_data_access: RAM_STORE # elevation: @@ -135,7 +133,6 @@ ors: # interpolate_bridges_and_tunnels: true # preparation: # min_network_size: 200 -# min_one_way_network_size: 200 # methods: # lm: # enabled: true @@ -145,7 +142,6 @@ ors: # execution: # methods: # lm: -# disabling_allowed: true # active_landmarks: 8 profiles: car: @@ -158,7 +154,6 @@ ors: # use_acceleration: true # preparation: # min_network_size: 200 -# min_one_way_network_size: 200 # methods: # ch: # enabled: true @@ -177,13 +172,9 @@ ors: # lmsets: highways;allow_all # execution: # methods: -# ch: -# disabling_allowed: true # lm: -# disabling_allowed: true # active_landmarks: 6 # core: -# disabling_allowed: true # active_landmarks: 6 # ext_storages: # WayCategory: @@ -203,7 +194,6 @@ ors: # elevation: true # preparation: # min_network_size: 200 -# min_one_way_network_size: 200 # methods: # ch: # enabled: true @@ -217,10 +207,7 @@ ors: # lmsets: highways;allow_all # execution: # methods: -# ch: -# disabling_allowed: true # core: -# disabling_allowed: true # active_landmarks: 6 # ext_storages: # WayCategory: