Skip to content

Commit

Permalink
Edits in docker and docker-compose to enable an easier and more custo…
Browse files Browse the repository at this point in the history
…mizable deployment
  • Loading branch information
TimMcCauley authored and Adam Rousell committed Mar 15, 2019
1 parent 3b1d601 commit 22330a8
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 98,635 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added support for ISO 3166-1 Alpha-2 / Alpha-3 codes for routing directions option avoid_countries (Issue #195)
- Added support for free hand route option/ skip segments (Issue #167)
- Added check on matrix service to make sure that the requested locations are within the bounding area of the graph (Issue #408)
- Makes docker and docker-compose deployment of openrouteservice more customizable (Issue #434)
### Fixed
- Fixed `geometry_simplify` parameter, which had no effect before. `geometry_simplify` is incompatible with `extra_info` (#381)
### Changed
Expand Down
53 changes: 41 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,52 @@
FROM maven:3-jdk-8
FROM openjdk:8-jdk

# This will supress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
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"
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
# `installAtEnd` and `deployAtEnd`are only effective with recent version of the corresponding plugins.
ENV MAVEN_CLI_OPTS="--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"

ARG APP_CONFIG=docker/conf/app.config.sample
ARG OSM_FILE=docker/data/heidelberg.osm.gz
ARG JAVA_OPTS
ARG CATALINA_OPTS

# Install required deps
RUN apt-get update -qq
RUN apt-get install -qq -y locales wget nano maven

RUN mkdir -p /ors-core/build
# Set the locale
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

COPY .git /ors-core/.git
RUN mkdir /ors-core
# Copy ors sources
COPY openrouteservice /ors-core/openrouteservice
COPY $APP_CONFIG /ors-core/openrouteservice/WebContent/WEB-INF/app.config

# Copy osm data file, config and cache if provided (ors will download otherwise)
COPY $OSM_FILE /ors-core/data/osm_file.pbf
COPY $APP_CONFIG /ors-core/openrouteservice/src/main/resources/app.config

WORKDIR /ors-core

# Build and install openrouteservice
RUN mvn -f ./openrouteservice/pom.xml package -DskipTests
# Build openrouteservice
RUN mvn -q -f ./openrouteservice/pom.xml package -DskipTests

# Install tomcat
RUN mkdir /usr/local/tomcat
RUN wget -q https://archive.apache.org/dist/tomcat/tomcat-8/v8.0.32/bin/apache-tomcat-8.0.32.tar.gz -O /tmp/tomcat.tar.gz

RUN cd /tmp && tar xvfz tomcat.tar.gz
RUN cp -R /tmp/apache-tomcat-8.0.32/* /usr/local/tomcat/

# Add tomcat custom settings if provided
RUN touch /usr/local/tomcat/bin/setenv.sh
RUN echo "CATALINA_OPTS=\"$CATALINA_OPTS\"" >> /usr/local/tomcat/bin/setenv.sh
RUN echo "JAVA_OPTS=\"$JAVA_OPTS\"" >> /usr/local/tomcat/bin/setenv.sh

# Copy ors app into tomcat webapps
RUN cp /ors-core/openrouteservice/target/*.war /usr/local/tomcat/webapps/ors.war

# Start the container
EXPOSE 8080
CMD /usr/local/tomcat/bin/catalina.sh run

CMD ORS_VER=$(mvn -f ./openrouteservice/pom.xml -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec) && cp /ors-core/openrouteservice/target/openrouteservice-$ORS_VER.war /ors-core/build/ors.war
52 changes: 12 additions & 40 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,25 @@
# Install and run openrouteservice with docker

Installing the openrouteservice backend service with **Docker** is quite straightforward. Please note that the [Dockerfile](../Dockerfile) located in the repository root directory is merely for building the [WAR file](https://www.wikiwand.com/en/WAR_(file_format)).
Installing the openrouteservice backend service with **Docker** is quite straightforward.

## Short version

Please clone the repository (downloading the archive and running docker is currently not supported) and run the following command within this `docker/` directory:
Please clone the repository and run the following command within this `docker/` directory:

```bash
sudo docker-compose up -d
docker-compose up -d
```

This will:

1. Build and test the openrouteservice core from the local codebase with the `docker/conf/app.config.sample` as the config file and the OpenStreetMap dataset for Heidelberg under `docker/data/` as sample data.
2. Generate the built `ors.war` file and expose it to `docker/build/` directory.
3. Launch the openrouteservice service on port `8080` within a tomcat container.

By default the service status is queryable via the `http://localhost:8080/ors/health` endpoint. When the service is ready, you will be able to request `http://localhost:8080/ors/status` for further information on the running services. If you use the default dataset you will be able to request `http://localhost:8080/ors/routes?profile=foot-walking&coordinates=8.676581,49.418204|8.692803,49.409465` for test purposes.

## Long version

### WAR file building

For building the WAR file only, either run

```bash
docker run -v /Users/user/build:/ors-core/build giscience/openrouteservice
```

or

```bash
docker-compose up ors-build
```

If everything goes fine, the built `ors.war` archive can be found under the shared host directory, e.g. `/Users/user/build` for the above `docker run` command or `./build/` for the `docker-compose` command.

### Run openrouteservice

No matter whether the WAR file has been built or not, simply run:

```bash
sudo docker-compose up
```
1. Build the openrouteservice [war file](https://www.wikiwand.com/en/WAR_(file_format)) from the local codebase with the `docker/conf/app.config.sample` as the config file and the OpenStreetMap dataset for Heidelberg under `docker/data/` as sample data.
2. Launch the openrouteservice service on port `8080` within a tomcat container.

will take care of all steps with the sample Heidelberg dataset.
By default the service status is queryable via the `http://localhost:8080/ors/health` endpoint. When the service is ready, you will be able to request `http://localhost:8080/ors/status` for further information on the running services.
If you use the default dataset you will be able to request `http://localhost:8080/ors/routes?profile=foot-walking&coordinates=8.676581,49.418204|8.692803,49.409465` for test purposes.

### Run with your own OpenStreetMap dataset
## Run with your own OpenStreetMap dataset

Prepare the OSM dataset (formats supported are `.osm`, `.osm.gz`, `.osm.zip` and `.pbf`) in the `docker/data/` directory. Adapt your own `app.config` (check the sample with detailed comments [here](../openrouteservice/WebContent/WEB-INF/app.config.sample) for reference) and change the `APP_CONFIG` variable in `docker-compose.yml` to let it point to your customized `app.config`. Then, run `docker-compose up`.
Save your OSM dataset (formats supported are `.osm`, `.osm.gz`, `.osm.zip` and `.pbf`) in the `docker/data/` directory and then adapt `docker-compose.yml`.
Afterwards run `docker-compose up -d` (if you want to rebuild graphs with a new OSM file first of all delete the contents of the `docker/graphs` folder and restart the service with `docker-compose up -d`).

It should be mentioned that if your dataset is very large, please adjust the `-Xmx` parameter of `JAVA_OPTS` in `docker-compose.yml`. According to our experience, this should be at least `180g` for the whole globe if you are planning to use 3 or more modes of transport.
It should be mentioned that if your dataset is very large, please adjust the `-Xmx` parameter of `JAVA_OPTS` in `docker-compose.yml`.
According to our experience, this should be at least `180g` for the whole globe if you are planning to use 3 or more modes of transport at the same time.
16 changes: 8 additions & 8 deletions docker/conf/app.config.sample
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"enabled":true,
"mode":"normal",
"sources":[
"data/heidelberg.osm.gz"
"data/osm_file.pbf"
],
"init_threads":1,
"attribution":"openrouteservice.org, OpenStreetMap contributors",
Expand All @@ -60,8 +60,8 @@
"default_params": {
"encoder_flags_size": 8,
"graphs_root_path": "data/graphs",
"elevation_provider": "cgiar",
"elevation_cache_path": "data/cgiar_provider",
"elevation_provider": "multi",
"elevation_cache_path": "data/elevation_cache",
"elevation_clear_cache": true,
"instructions": true,
"maximum_distance": 100000,
Expand Down Expand Up @@ -280,11 +280,11 @@
}
}
},
"logging":{
"enabled":true,
"level_file":"DEBUG_LOGGING.json",
"location":"./logs",
"stdout":true
"logging": {
"enabled": true,
"level_file": "PRODUCTION_LOGGING.json",
"location": "/var/log/ors",
"stdout": true
}
}
}
Binary file added docker/data/elevation_cache/srtm_38_03.zip
Binary file not shown.
Loading

0 comments on commit 22330a8

Please sign in to comment.