From cec8dfe38d9218f9c8ae272630eaedc19797877d Mon Sep 17 00:00:00 2001 From: Sachin Goel Date: Thu, 16 Jan 2025 13:02:18 -0800 Subject: [PATCH] feat: add `Dockerfile` to project We want to add a `Dockerfile` to our fork of OpenRailRouting so that we can publish the built docker image to our private docker registry in order to reference it in our future tile generation pipeline for building tiles --- .dockerignore | 4 ++++ Dockerfile | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ac09c5b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git +target +*.log +Dockerfile \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d0bc5a6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +FROM maven:3.9.5-eclipse-temurin-21 + +# Install additional dependencies +RUN apt-get update && apt-get install -y \ + curl \ + tar \ + nodejs \ + npm \ + && rm -rf /var/lib/apt/lists/* + +# Set version of Graphhopper +ARG GH_VERSION=9.1-osm-reader-callbacks + +# Download Graphhopper source code +RUN curl -L https://github.com/geofabrik/graphhopper/archive/refs/tags/${GH_VERSION}.tar.gz -o graphhopper.tar.gz +RUN mkdir -p /openrailrouting/graphhopper && tar -xzf graphhopper.tar.gz -C /openrailrouting/graphhopper --strip-components=1 + +# Remove tarball +RUN rm graphhopper.tar.gz + +# Copy OpenRailRouting source code into the container +COPY . /openrailrouting + +# Set working directory to OpenRailRouting +WORKDIR /openrailrouting + +# Clear Maven repository to ensure a fresh build +RUN rm -rf ~/.m2/repository/* + +# Build OpenRailRouting and Graphhopper using Maven +RUN mvn clean install -DskipTests + +# Expose necessary ports and run the application +EXPOSE 8989 + +CMD java -Xmx2G -Xms512m \ + -Ddw.graphhopper.graph.location=/openrailrouting/osm/data-gh \ + -Ddw.graphhopper.datareader.file=${OSM_PATH} \ + -jar target/railway_routing-1.0.0.jar server ./config.yml