Minimized ICS Java 17 image

Issue-ID: NONRTRIC-845
Signed-off-by: BjornMagnussonXA <bjorn.magnusson@est.tech>
Change-Id: Ia2c3dba8febfae2d94f672e3127fa1cdd1233ab7
diff --git a/Dockerfile b/Dockerfile
index 79c6380..4dd4a46 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -17,7 +17,25 @@
 # SPDX-License-Identifier: Apache-2.0
 # ============LICENSE_END=========================================================
 #
-FROM openjdk:17-jdk-slim
+FROM openjdk:17-jdk as jre-build
+
+RUN $JAVA_HOME/bin/jlink \
+--verbose \
+--add-modules ALL-MODULE-PATH \
+--strip-debug \
+--no-man-pages \
+--no-header-files \
+--compress=2 \
+--output /customjre
+
+# Use debian base image (same as openjdk uses)
+FROM debian:11-slim
+
+ENV JAVA_HOME=/jre
+ENV PATH="${JAVA_HOME}/bin:${PATH}"
+
+#copy JRE from the base image
+COPY --from=jre-build /customjre $JAVA_HOME
 
 ARG JAR
 
@@ -44,7 +62,7 @@
 
 USER ${user}
 
-CMD ["java", "-jar", "/opt/app/information-coordinator-service/information-coordinator-service.jar"]
+CMD ["/jre/bin/java", "-jar", "/opt/app/information-coordinator-service/information-coordinator-service.jar"]