Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
target/
.git/
.idea/
.vscode/
.guthub/
*.iml
25 changes: 20 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"]
16 changes: 16 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layers>
<enabled>true</enabled>
</layers>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down