Minimized Dmaap adapter Java 17 image
Issue-ID: NONRTRIC-845
Signed-off-by: BjornMagnussonXA <bjorn.magnusson@est.tech>
Change-Id: I8b45eb746863ae3ee4200c998fbd74c1f9b628c3
diff --git a/Dockerfile b/Dockerfile
index 9af0345..fb2abe9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,7 +2,7 @@
# ============LICENSE_START=======================================================
# O-RAN-SC
# ================================================================================
-# Copyright (C) 2021 Nordix Foundation. All rights reserved.
+# Copyright (C) 2021-2023 Nordix Foundation. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,7 +20,25 @@
# ============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
EXPOSE 8084 8435
@@ -48,4 +66,4 @@
USER ${user}
ADD target/${JAR} /opt/app/dmaap-adapter-service/dmaap-adapter.jar
-CMD ["java", "-jar", "/opt/app/dmaap-adapter-service/dmaap-adapter.jar"]
+CMD ["/jre/bin/java", "-jar", "/opt/app/dmaap-adapter-service/dmaap-adapter.jar"]