From 15704fa7b8d9b0753f64cb7d4501372529cb76fb Mon Sep 17 00:00:00 2001 From: wlanboy Date: Mon, 12 Jan 2026 21:51:33 +0100 Subject: [PATCH 1/4] added docker ignore --- .dockerignore | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b8075e4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +target/ +.git/ +.idea/ +.vscode/ +.guthub/ +*.iml From a2aa62f6e6ba13aa0b14d8fc05b07b4629d2d271 Mon Sep 17 00:00:00 2001 From: wlanboy Date: Mon, 12 Jan 2026 21:52:00 +0100 Subject: [PATCH 2/4] entry point with params --- entrypoint.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..a874fbe --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -e + +# Wir nutzen exec, damit Java die PID 1 übernimmt. +# Dies ist wichtig für das Signal-Handling (z.B. in Kubernetes). +exec java \ + -Djava.security.egd=file:/dev/./urandom \ + -XX:SharedArchiveFile=application.jsa \ + -XX:MaxRAMPercentage=50 \ + -XX:InitialRAMPercentage=30 \ + -XX:+UseG1GC \ + -XX:MaxGCPauseMillis=200 \ + -XX:+ExplicitGCInvokesConcurrent \ + -XX:+ExitOnOutOfMemoryError \ + org.springframework.boot.loader.launch.JarLauncher \ + --spring.config.location=file:/app/config/application.properties \ No newline at end of file From 92193264c3d72aa7701c87c9fad2f5734756db4d Mon Sep 17 00:00:00 2001 From: wlanboy Date: Mon, 12 Jan 2026 21:52:11 +0100 Subject: [PATCH 3/4] added layer plugin --- pom.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pom.xml b/pom.xml index 5ce3b12..3a2bf3a 100644 --- a/pom.xml +++ b/pom.xml @@ -93,6 +93,15 @@ + + org.springframework.boot + spring-boot-maven-plugin + + + true + + + org.apache.maven.plugins maven-compiler-plugin From 2628ff04235f88b5f930135b46f315397d8a88fb Mon Sep 17 00:00:00 2001 From: wlanboy Date: Mon, 12 Jan 2026 21:52:28 +0100 Subject: [PATCH 4/4] cache mount and layer --- Dockerfile | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index d55259c..7796f8d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,14 +7,18 @@ WORKDIR /app # Erst nur die Dependencies COPY --chown=185:0 pom.xml . -RUN mvn -q -DskipTests dependency:go-offline +RUN --mount=type=cache,target=/root/.m2 mvn -q -DskipTests dependency:go-offline # Dann erst der Sourcecode COPY --chown=185:0 src ./src -RUN mvn -q -DskipTests package +RUN --mount=type=cache,target=/root/.m2 mvn -q -DskipTests package + +# Wir behalten das JAR für das Training UND extrahieren die Layer +RUN cp target/kubeevent-0.0.1-SNAPSHOT.jar app.jar && \ + java -Djarmode=layertools -jar app.jar extract # ============================ -# 2. Runtime Stage +# 3. Runtime Stage # ============================ FROM registry.access.redhat.com/ubi9/openjdk-21-runtime:latest @@ -30,9 +34,20 @@ RUN mkdir -p /app/config /app/data && \ USER 185 -COPY --from=build /app/target/kubeevent-0.0.1-SNAPSHOT.jar /app/kubeevent.jar +# Dependencies +COPY --from=build /app/dependencies/ ./ +COPY --from=build /app/spring-boot-loader/ ./ +COPY --from=build /app/snapshot-dependencies/ ./ + +# Application +COPY --from=build /app/application/ ./ + COPY config/application.properties /app/config/application.properties +COPY entrypoint.sh /app/entrypoint.sh EXPOSE 8080 -ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/app/kubeevent.jar", "--spring.config.location=file:/app/config/application.properties"] +HEALTHCHECK --interval=30s --timeout=3s \ + CMD curl -f http://localhost:8080/actuator/health || exit 1 + +ENTRYPOINT ["/app/entrypoint.sh"] \ No newline at end of file