Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configuration using YAML files #1506

Merged
merged 43 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
30246b7
refactor(config): migrate isochrone max range properties
aoles Jul 12, 2023
ca9a1da
refactor(config): get rid of RoutingServiceSettings
takb Jul 10, 2023
e0e61b3
feat: optinal config yml locations
takb Jul 14, 2023
7b43bf0
refactor(config): migrate isochrone statistics providers
aoles Jul 14, 2023
cb22e0f
refactor: move logic from Request classes to new service layer
jhaeu Jul 20, 2023
734efe6
refactor: move logic from IsochronesRequest to new IsochronesService
jhaeu Jul 20, 2023
3efb904
refactor: move logic from MatrixRequest to new MatrixService
jhaeu Jul 20, 2023
7a7f2ae
refactor: move logic from ExportRequest to new ExportService
jhaeu Jul 20, 2023
5c7c711
refactor: cleanup
jhaeu Jul 20, 2023
1a240f7
refactor: renamed test classes
jhaeu Jul 20, 2023
1c9a552
refactor: cleanup
jhaeu Jul 20, 2023
33d2b50
refactor: fix methods in ExportService, cleanup
jhaeu Jul 20, 2023
6f1d860
refactor(config): get rid of IsochronesServiceSettings
aoles Jul 20, 2023
437d9e1
refactor: cleanup
jhaeu Jul 20, 2023
2e4c551
refactor: cleanup unused imports
jhaeu Jul 21, 2023
23c8a6d
refactor: moved common property to super class
jhaeu Jul 21, 2023
f591ced
style: removed double blank lines
jhaeu Jul 21, 2023
11fff04
refactor: remove unused imports
jhaeu Jul 21, 2023
3e2227e
Merge branch 'refactor/ors_config' into refactor/ors_config_service
takb Jul 24, 2023
8efdbbd
refactor: move logic from Request classes to new service layer (#1503)
takb Jul 24, 2023
c8d80e1
feat: engine.profiles through yml
takb Jul 18, 2023
5548549
fix: api tests, remove json files
takb Jul 24, 2023
5628285
docs: changelog
takb Jul 24, 2023
9778b9b
Merge branch 'master' into refactor/ors_config
takb Jul 24, 2023
e45fc2e
build:docker setup
takb Jul 24, 2023
86a7773
fix: max_alt_routes param
takb Jul 24, 2023
f898b01
fix(apitest): move example profiles
takb Jul 24, 2023
19a1077
Merge branch 'master' into refactor/ors_config
takb Jul 24, 2023
19374a3
chore: code formatting
takb Jul 25, 2023
4a7fcea
Merge branch 'master' into refactor/ors_config
takb Jul 25, 2023
67e3eb6
docs: configuration.md WIP
takb Jul 25, 2023
dd0bad7
fix: parameter precedence of environment/runtime before ors-config.yml
takb Jul 25, 2023
c5dbdf7
feat: use namespace ors for all ors specific properties
takb Jul 25, 2023
52f4fd1
feat: config file locations via arg/env
takb Jul 26, 2023
b8ac596
Revert "chore: code formatting"
takb Jul 26, 2023
772b05a
fix: cors check
takb Jul 26, 2023
f0fcf3c
build: docker-compose shjould pull image
takb Jul 26, 2023
580204b
Merge branch 'master' into refactor/ors_config
takb Jul 27, 2023
fca382e
fix: requested changes
takb Jul 27, 2023
48e5ca6
fix: docker test
takb Jul 27, 2023
9471aa8
feat: example conf and deprecation
takb Jul 28, 2023
b9772d6
fix: entrypoint script
takb Jul 28, 2023
f7a6472
style: typo
takb Jul 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs:
run: |
mkdir $(pwd)/graphs $(pwd)/conf
sudo chown 1000:1000 $(pwd)/graphs $(pwd)/conf
docker run -it -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 }}
docker run -it -d -p 8080:8080 --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
Expand All @@ -122,7 +122,7 @@ jobs:
# Restart the container to apply the config changes
docker stop ors-instance
docker container prune -f
docker run -it -d -p 8080:8080 -v $(pwd)/graphs:/home/ors/ors-core/data/graphs -v $(pwd)/conf:/home/ors/ors-conf -e CORS_ALLOWED_ORIGINS=https://example.org --name ors-instance ${{ needs.prepare_environment.outputs.test_image_name }}
docker run -it -d -p 8080:8080 -e ORS_CORS_ALLOWED_ORIGINS=https://example.org --name ors-instance ${{ needs.prepare_environment.outputs.test_image_name }}
MichaelsJP marked this conversation as resolved.
Show resolved Hide resolved
# 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.
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ RELEASING:
- `PBF_FILE_PATH`: value to overwrite the `ors.services.routing.sources` with
- add .editorconfig to streamline IDE code styling ([#1493](https://github.com/GIScience/openrouteservice/pull/1493))
- info on duration format in parameter description ([#1504](https://github.com/GIScience/openrouteservice/pull/1504))
- YML configuration ([#1506](https://github.com/GIScience/openrouteservice/pull/1506))

### Changed
- url_check.sh to support custom sleep and reporting intervals ([#1468](https://github.com/GIScience/openrouteservice/pull/1468))
Expand All @@ -55,6 +56,9 @@ RELEASING:
- spring-boot-starter-parent to v3.1.1 ([#1504](https://github.com/GIScience/openrouteservice/pull/1504))
- from springdoc-openapi-ui package to springdoc-openapi-starter-webmvc-ui ([#1504](https://github.com/GIScience/openrouteservice/pull/1504))

### Deprecated
- JSON configuration and related classes ([#1506](https://github.com/GIScience/openrouteservice/pull/1506))

### Removed
- dependency on apache-curator ([#1496](https://github.com/GIScience/openrouteservice/issues/1496))
- ORSKafkaConsumer and related classes ([#1482](https://github.com/GIScience/openrouteservice/pull/1482))
Expand Down
36 changes: 10 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ RUN wget -q https://archive.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR}/v${TOM
mv /tmp/apache-tomcat-${TOMCAT_VERSION}/ /tmp/tomcat && \
echo "org.apache.catalina.level = WARNING" >> /tmp/tomcat/conf/logging.properties


FROM base as build

# hadolint ignore=DL3002
Expand All @@ -37,27 +36,11 @@ 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"

ARG ORS_CONFIG=ors-api/src/main/resources/ors-config-sample.json

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_CONFIG /ors-core/ors-api/src/main/resources/ors-config.json

# Configure ors config:
# Fist set pipefail to -c to allow intermediate pipes to throw errors
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# - Replace paths in ors-config.json to match docker setup
# - init_threads = 1, > 1 been reported some issues
# - Delete all profiles but car
RUN jq '.ors.services.routing.sources[0] = "/home/ors/ors-core/data/osm_file.pbf"' /ors-core/ors-api/src/main/resources/ors-config.json | sponge /ors-core/ors-api/src/main/resources/ors-config.json && \
jq '.ors.logging.location = "/home/ors/ors-core/logs/ors"' /ors-core/ors-api/src/main/resources/ors-config.json | sponge /ors-core/ors-api/src/main/resources/ors-config.json && \
jq '.ors.services.routing.profiles.default_params.elevation_cache_path = "/home/ors/ors-core/data/elevation_cache"' /ors-core/ors-api/src/main/resources/ors-config.json | sponge /ors-core/ors-api/src/main/resources/ors-config.json && \
jq '.ors.services.routing.profiles.default_params.graphs_root_path = "/home/ors/ors-core/data/graphs"' /ors-core/ors-api/src/main/resources/ors-config.json | sponge /ors-core/ors-api/src/main/resources/ors-config.json && \
jq '.ors.services.routing.init_threads = 1' /ors-core/ors-api/src/main/resources/ors-config.json | sponge /ors-core/ors-api/src/main/resources/ors-config.json && \
jq 'del(.ors.services.routing.profiles.active[1,2,3,4,5,6,7,8])' /ors-core/ors-api/src/main/resources/ors-config.json | sponge /ors-core/ors-api/src/main/resources/ors-config.json

RUN mvn package -DskipTests

Expand All @@ -82,23 +65,24 @@ ENV LANG='en_US' LANGUAGE='en_US' LC_ALL='en_US'
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/ors ${BASE_FOLDER}/ors-conf ${BASE_FOLDER}/tomcat/logs && \
chown -R ors ${BASE_FOLDER}/tomcat ${BASE_FOLDER}/ors-core/logs/ors ${BASE_FOLDER}/ors-conf ${BASE_FOLDER}/tomcat/logs
mkdir -p ${BASE_FOLDER}/logs ${BASE_FOLDER}/graphs ${BASE_FOLDER}/elevation_cache ${BASE_FOLDER}/conf ${BASE_FOLDER}/data ${BASE_FOLDER}/tomcat/logs&& \
chown -R ors ${BASE_FOLDER}/logs ${BASE_FOLDER}/graphs ${BASE_FOLDER}/elevation_cache ${BASE_FOLDER}/conf ${BASE_FOLDER}/data ${BASE_FOLDER}/tomcat ${BASE_FOLDER}/tomcat/logs
MichaelsJP marked this conversation as resolved.
Show resolved Hide resolved

WORKDIR ${BASE_FOLDER}

# Copy over the needed bits and pieces from the other stages.
COPY --chown=ors:ors --from=build /ors-core/ors-api/target/ors.war ${BASE_FOLDER}/ors-core/ors.war
COPY --chown=ors:ors --from=build /ors-core/ors-api/src/main/resources/ors-config.json ${BASE_FOLDER}/ors-core/ors-config.json
COPY --chown=ors:ors --from=tomcat /tmp/tomcat ${BASE_FOLDER}/tomcat
COPY --chown=ors:ors --from=build /ors-core/ors-api/src/main/resources/log4j.properties ${BASE_FOLDER}/tomcat/lib/log4j.properties
COPY --chown=ors:ors ./docker-entrypoint.sh ${BASE_FOLDER}/ors-core/docker-entrypoint.sh
COPY --chown=ors:ors ./$OSM_FILE ${BASE_FOLDER}/ors-core/data/osm_file.pbf
COPY --chown=ors:ors --from=build /ors-core/ors-api/target/ors.war ${BASE_FOLDER}/tomcat/webapps/ors.war
COPY --chown=ors:ors --from=build /ors-core/ors-api/src/main/resources/log4j.properties ${BASE_FOLDER}/tomcat/conf/logging.properties
COPY --chown=ors:ors ./docker-entrypoint.sh ${BASE_FOLDER}/docker-entrypoint.sh
COPY --chown=ors:ors ./ors-api/ors-config.yml ${BASE_FOLDER}/tmp/ors-config.yml
COPY --chown=ors:ors ./$OSM_FILE ${BASE_FOLDER}/tmp/osm_file.pbf

USER ${UID}:${GID}

ENV BUILD_GRAPHS="False"
ENV ORS_CONFIG_LOCATION=conf/ors-config.yml

# Start the container
ENTRYPOINT ["/home/ors/ors-core/docker-entrypoint.sh"]
CMD ["/home/ors"]
ENTRYPOINT ["/home/ors/docker-entrypoint.sh"]
CMD ["/home/ors"]
11 changes: 5 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ services:
# build:
# context: ./
# args:
# ORS_CONFIG: ./ors-api/src/main/resources/ors-config-sample.json
# 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/ors-core/logs/ors
- ./docker/graphs:/home/ors/graphs
- ./docker/elevation_cache:/home/ors/elevation_cache
- ./docker/logs/ors:/home/ors/logs
- ./docker/logs/tomcat:/home/ors/tomcat/logs
- ./docker/conf:/home/ors/ors-conf
#- ./your_osm.pbf:/home/ors/ors-core/data/osm_file.pbf
- ./docker/conf:/home/ors/conf
- ./docker/data:/home/ors/data
takb marked this conversation as resolved.
Show resolved Hide resolved
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"
Expand Down
25 changes: 8 additions & 17 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ fi

ors_base=${1}
catalina_base=${ors_base}/tomcat
graphs=${ors_base}/graphs

echo "ORS Path: ${ors_base}"
echo "Catalina Path: ${catalina_base}"

graphs=${ors_base}/ors-core/data/graphs
tomcat_ors_config=${catalina_base}/webapps/ors/WEB-INF/classes/ors-config.json
source_ors_config=${ors_base}/ors-core/ors-config.json
public_ors_config_folder=${ors_base}/ors-conf
public_ors_config=${public_ors_config_folder}/ors-config.json
ors_war_path=${ors_base}/ors-core/ors.war

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"
Expand All @@ -42,20 +38,15 @@ if [ "${BUILD_GRAPHS}" = "True" ]; then
fi

echo "### openrouteservice configuration ###"
if [ ! -d "${catalina_base}/webapps/ors" ]; then
echo "Extract war file to ${catalina_base}/webapps/ors"
cp -f "${ors_war_path}" "${catalina_base}"/webapps/ors.war
unzip -qq "${catalina_base}"/webapps/ors.war -d "${catalina_base}/webapps/ors"
if [ ! -f "${ors_base}/conf/ors-config.yml" ]; then
echo "Copy ors-config.yml"
cp -f "${ors_base}/tmp/ors-config.yml" "${ors_base}/conf/ors-config.yml"
fi

if [ ! -f "$public_ors_config" ]; then
echo "No ors-config.json in ors-conf folder. Copying original config from ${source_ors_config}"
mkdir -p "${public_ors_config_folder}"
cp -f "${source_ors_config}" "${public_ors_config}"
if [ ! -f "${ors_base}/data/osm_file.pbf" ]; then
echo "Copy osm_file.pbf"
cp -f "${ors_base}/tmp/osm_file.pbf" "${ors_base}/data/osm_file.pbf"
fi

echo "Deploy ors with config from ${public_ors_config}"
cp -f "${public_ors_config}" "${tomcat_ors_config}"

# so docker can stop the process gracefully
exec "${catalina_base}"/bin/catalina.sh run
Loading