From dbdb17382c20b679b7eb24aef1660522a5a8ad08 Mon Sep 17 00:00:00 2001 From: acabello Date: Mon, 16 Jun 2025 23:48:19 +0200 Subject: [PATCH 1/2] updated to work in 2025 matsim --- Dockerfile | 9 +- docker-entrypoint.sh | 1 + pom.xml | 342 ++++++++++++++++++++++++++++--------------- 3 files changed, 230 insertions(+), 122 deletions(-) diff --git a/Dockerfile b/Dockerfile index 581e618..42e66c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG APP_DIR=/opt/matsim -FROM maven:3.8.6-openjdk-18-slim AS build +FROM maven:3.9-eclipse-temurin-21 AS build ARG APP_DIR WORKDIR ${APP_DIR} COPY . ./ @@ -12,13 +12,14 @@ RUN mvn -f pom.xml -DskipTests clean package \ && figlet -f slant "MATSim $(cat VERSION.txt)" > BANNER.txt \ && echo "Image build date: $(date --iso-8601=seconds)" >> BANNER.txt -FROM openjdk:18-slim +FROM eclipse-temurin ARG APP_DIR LABEL maintainer="Merlin Unterfinger " WORKDIR ${APP_DIR} COPY docker-entrypoint.sh ./ +RUN chmod +x docker-entrypoint.sh COPY --from=build ${APP_DIR}/*.txt ./resources/ -COPY --from=build ${APP_DIR}/target/*-jar-with-dependencies.jar ./matsim.jar +COPY --from=build ${APP_DIR}/matsim-example-project-0.0.1-SNAPSHOT.jar ./matsim.jar ENV MATSIM_HOME=${APP_DIR} \ MATSIM_INPUT=${APP_DIR}/data/input \ MATSIM_OUTPUT=${APP_DIR}/data/output @@ -29,4 +30,4 @@ RUN apt-get update && apt-get install -y \ && mkdir -p ${MATSIM_INPUT} \ && mkdir -p ${MATSIM_OUTPUT} VOLUME ${APP_DIR}/data -ENTRYPOINT ["./docker-entrypoint.sh", "java", "-jar", "matsim.jar"] +ENTRYPOINT ["./docker-entrypoint.sh", "java", "-cp", "matsim.jar", "org.matsim.run.RunMatsim", "/opt/matsim/data/input/config.xml"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 1440c13..de6c3bc 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -25,6 +25,7 @@ input files from the host to the conatiner: [...] \\ maptic/matsim:latest +Make sure the input directory has a file named config.xml Exiting." printf '%s\n' "$help_text_input" } diff --git a/pom.xml b/pom.xml index 67c19bd..7bc4099 100644 --- a/pom.xml +++ b/pom.xml @@ -1,118 +1,224 @@ - - - - 4.0.0 - - ch.maptic - matsim-docker - 15.0-2022w40 - - matsim-docker - http://www.maptic.ch - - - UTF-8 - 18 - 18 - 25.0-PR3212 - - - - - matsim - MATSim Maven repository - https://repo.matsim.org/repository/matsim/ - - - - - - org.matsim - matsim - ${matsim.version} - - - org.junit.jupiter - junit-jupiter - 5.12.2 - test - - - - - - - - - maven-clean-plugin - 3.4.1 - - - - maven-resources-plugin - 3.3.1 - - - maven-compiler-plugin - 3.14.0 - - - maven-surefire-plugin - 3.5.3 - - - ${matsim.version} - test/input - test/output - - - - - maven-jar-plugin - 3.4.2 - - - maven-assembly-plugin - 3.7.1 - - - - true - ch.maptic.matsim.docker.DockerEntrypoint - - - - jar-with-dependencies - - - - - make-assembly - package - - single - - - - - - maven-install-plugin - 3.1.4 - - - maven-deploy-plugin - 3.1.4 - - - - maven-site-plugin - 3.21.0 - - - maven-project-info-reports-plugin - 3.9.0 - - - - \ No newline at end of file + + + + org.matsim + matsim-all + + + + 2025.0 + + + 4.0.0 + matsim-example-project + 0.0.1-SNAPSHOT + + MATSim example project + MATSim example project + + + + + ${parent.version} + + UTF-8 + UTF-8 + 21 + + + + + + + osgeo + Geotools repository + + https://repo.osgeo.org/repository/release/ + + + + matsim + https://repo.matsim.org/repository/matsim + + + + topobyte + https://mvn.topobyte.de + + + + slimjars + https://mvn.slimjars.com + + + + + + + org.matsim + matsim + ${matsim.version} + + + + org.junit.jupiter + junit-jupiter-engine + 5.10.2 + test + + + + + org.matsim + matsim + test-jar + ${matsim.version} + test + + + + + + org.matsim + matsim-examples + ${matsim.version} + + + + + + + + + org.matsim.contrib + minibus + ${matsim.version} + + + org.matsim.contrib + otfvis + ${matsim.version} + + + org.matsim.contrib + noise + ${matsim.version} + + + org.matsim.contrib + roadpricing + ${matsim.version} + + + org.matsim.contrib + taxi + ${matsim.version} + + + org.matsim.contrib + av + ${matsim.version} + + + org.matsim.contrib + freight + ${matsim.version} + + + org.matsim.contrib + bicycle + ${matsim.version} + + + org.matsim.contrib + emissions + ${matsim.version} + + + org.matsim.contrib + application + ${matsim.version} + + + org.matsim.contrib + simwrapper + ${matsim.version} + + + org.matsim.contrib + vsp + ${matsim.version} + + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-eclipse-plugin + 2.10 + + true + true + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.4.1 + + + package + + shade + + + ${project.basedir}/${project.build.finalName}.jar + + + + + org.matsim.gui.MATSimGUI + org.matsim + org.matsim + ${project.version} + + + + + + + + *:* + + META-INF/*.RSA + META-INF/*.SF + META-INF/*.RSA + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + + + From 080bcfdc9c15f1bd531d9484878ad8f51b9c4cc8 Mon Sep 17 00:00:00 2001 From: acabello Date: Tue, 17 Jun 2025 23:22:55 +0200 Subject: [PATCH 2/2] Fix: support JAVA_HEAP in entrypoint script --- docker-entrypoint.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index de6c3bc..64e4610 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -70,4 +70,11 @@ _print_header _check_input_directory _check_output_directory printf '%s\n' "" -exec "$@" + +if [ "$1" = "java" ]; then + : "${JAVA_HEAP:=-Xms512m -Xmx2g}" + shift + exec java $JAVA_HEAP "$@" +else + exec "$@" +fi