Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 . ./
Expand All @@ -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 <merlin.unterfinger@maptic.ch>"
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
Expand All @@ -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"]
10 changes: 9 additions & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -69,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
342 changes: 224 additions & 118 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,118 +1,224 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>ch.maptic</groupId>
<artifactId>matsim-docker</artifactId>
<version>15.0-2022w40</version>

<name>matsim-docker</name>
<url>http://www.maptic.ch</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
<matsim.version>25.0-PR3212</matsim.version>
</properties>

<repositories>
<repository>
<id>matsim</id>
<name>MATSim Maven repository</name>
<url>https://repo.matsim.org/repository/matsim/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.matsim</groupId>
<artifactId>matsim</artifactId>
<version>${matsim.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.12.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.1</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.3</version>
<configuration>
<environmentVariables>
<MATSIM_VERSION>${matsim.version}</MATSIM_VERSION>
<MATSIM_INPUT>test/input</MATSIM_INPUT>
<MATSIM_OUTPUT>test/output</MATSIM_OUTPUT>
</environmentVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.7.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>ch.maptic.matsim.docker.DockerEntrypoint</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.4</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.4</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.21.0</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.9.0</version>
</plugin>
</plugins>
</build>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>
<groupId>org.matsim</groupId>
<artifactId>matsim-all</artifactId>

<!-- Options: stable build based on pull requests (e.g. 16.0-PR2778), weekly (e.g. 15.0-2023w01) or official (e.g. 14.0) releases -->
<!-- <version>16.0-PR2509</version>-->
<version>2025.0</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>matsim-example-project</artifactId>
<version>0.0.1-SNAPSHOT</version>

<name>MATSim example project</name>
<description>MATSim example project</description>

<properties>

<!-- Don't change version here, but in the parent section above! -->
<matsim.version>${parent.version}</matsim.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.release>21</maven.compiler.release>
</properties>

<repositories>
<!--Note that in general repositories are not transitive, so they need to be repeated at every level where needed.-->
<repository>
<!-- Geotools is not on Maven central -->
<id>osgeo</id>
<name>Geotools repository</name>
<!-- <url>http://download.osgeo.org/webdav/geotools</url> -->
<url>https://repo.osgeo.org/repository/release/</url>
</repository>
<repository>
<!-- Repository for MATSim (MATSim is not on Maven central, releases and snapshots) -->
<id>matsim</id>
<url>https://repo.matsim.org/repository/matsim</url>
</repository>
<!-- for dependencies of osm-network-reader -->
<repository>
<id>topobyte</id>
<url>https://mvn.topobyte.de</url>
</repository>
<!-- for dependencies of osm-network-reader -->
<repository>
<id>slimjars</id>
<url>https://mvn.slimjars.com</url>
</repository>
</repositories>

<dependencies>
<dependency>
<!-- This is the matsim "core": -->
<groupId>org.matsim</groupId>
<artifactId>matsim</artifactId>
<version>${matsim.version}</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>

<dependency>
<!--MATSim test infrastructure. Not transitive.-->
<groupId>org.matsim</groupId>
<artifactId>matsim</artifactId>
<type>test-jar</type>
<version>${matsim.version}</version>
<scope>test</scope>
</dependency>

<!--dependencies from here to where stated below are added as a service; they can be removed if you don't need them-->
<!--to get ExamplesUtils: -->
<dependency>
<groupId>org.matsim</groupId>
<artifactId>matsim-examples</artifactId>
<version>${matsim.version}</version>
<!-- <scope>test</scope>-->
<!-- I think that having it in the "main" scope is acceptable for a "leaf" project, and makes life easier. move the-->
<!-- matsim-examples dependency into "test" scope if you want to make other projects dependent on your this project here. kai,-->
<!-- jan'21-->
</dependency>

<!--some contribs:-->
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>minibus</artifactId>
<version>${matsim.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>otfvis</artifactId>
<version>${matsim.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>noise</artifactId>
<version>${matsim.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>roadpricing</artifactId>
<version>${matsim.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>taxi</artifactId>
<version>${matsim.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>av</artifactId>
<version>${matsim.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>freight</artifactId>
<version>${matsim.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>bicycle</artifactId>
<version>${matsim.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>emissions</artifactId>
<version>${matsim.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>application</artifactId>
<version>${matsim.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>simwrapper</artifactId>
<version>${matsim.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>vsp</artifactId>
<version>${matsim.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.matsim.contrib</groupId>-->
<!-- <artifactId>simwrapper</artifactId>-->
<!-- <version>${matsim.version}</version>-->
<!-- </dependency>-->

<!--Dependencies from where stated above to here are added as a service; they can be removed if you don't need them-->

</dependencies>

<build>
<plugins>
<plugin>
<!-- This plugin makes source files and javadocs available inside eclipse. In IntelliJ, this works without plugin.-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.10</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<!-- The maven-shade-plugin replaces the maven-assembly-plugin to configure "mvn package". The assembly-plugin regularly-->
<!-- creates problems when GeoTools are used, which the shade-plugin does not (see-->
<!-- https://stackoverflow.com/questions/27429097/geotools-cannot-find-hsql-epsg-db-throws-error-nosuchauthoritycodeexception/27431381#27431381)-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<outputFile>${project.basedir}/${project.build.finalName}.jar</outputFile>
<transformers>
<!-- The following sets the main class for the executable jar as you otherwise would with the assembly plugin -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>org.matsim.gui.MATSimGUI</Main-Class>
<Specification-Vendor>org.matsim</Specification-Vendor>
<Implementation-Vendor>org.matsim</Implementation-Vendor>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
</transformer>
<!-- The following merges the various GeoTools META-INF/services files -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.RSA</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
</plugin>
</plugins>
</build>
</project>