This is an automated email from the ASF dual-hosted git repository.
jfeinauer pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new 7069cbc Optimizing JRE for size and adding dynamic option setting for
example jar
7069cbc is described below
commit 7069cbc9d392a7b3b53edf2f9af2864e0ddfb580
Author: Roman Shaposhnik <[email protected]>
AuthorDate: Sun Sep 8 16:45:14 2019 -0700
Optimizing JRE for size and adding dynamic option setting for example jar
Signed-off-by: Roman Shaposhnik <[email protected]>
---
Dockerfile | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 26c62ea..3771197 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -77,11 +77,39 @@ RUN ./mvnw
org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpressio
# Move the file to a place we can reference it from without a version
RUN PROJECT_VERSION=`cat project_version`; mv
plc4j/examples/hello-storage-elasticsearch/target/plc4j-hello-storage-elasticsearch-$PROJECT_VERSION-uber-jar.jar
plc4xdemo.jar
+# Build a highly optimized JRE
+FROM alpine:3.10 as packager
+
+# Install regular JDK
+RUN apk update
+RUN apk --no-cache add openjdk11-jdk openjdk11-jmods
+
+# build minimal JRE
+ENV JAVA_MINIMAL="/opt/java-minimal"
+RUN /usr/lib/jvm/java-11-openjdk/bin/jlink \
+ --verbose \
+ --add-modules \
+
java.base,java.sql,java.naming,java.desktop,java.management,java.security.jgss,java.instrument
\
+ --compress 2 --strip-debug --no-header-files --no-man-pages \
+ --release-info="add:IMPLEMENTOR=radistao:IMPLEMENTOR_VERSION=radistao_JRE"
\
+ --output "$JAVA_MINIMAL"
+
# Now create an actuall deployment container
-FROM azul/zulu-openjdk:latest
+FROM alpine:3.10
+
+# Install our optimized JRE
+ENV JAVA_HOME=/opt/java-minimal
+ENV PATH="$PATH:$JAVA_HOME/bin"
+COPY --from=packager "$JAVA_HOME" "$JAVA_HOME"
# Prepare the demo by copying the example artifact from the 'build' container
into this new one.
COPY --from=build /ws/plc4xdemo.jar /plc4xdemo.jar
+# Let runtime know which ports we will be listening on
+EXPOSE 9200 9300
+
+# Allow for extra options to be passed to the jar using PLC4X_OPTIONS env
variable
+ENV PLC4X_OPTIONS ""
+
# This will be executed as soon as the container is started.
-ENTRYPOINT ["java", "-jar", "/plc4xdemo.jar"]
\ No newline at end of file
+ENTRYPOINT ["sh", "-c", "[ -f /run/plc4xdemo.env ] && . /run/plc4xdemo.env ;
java -jar /plc4xdemo.jar $PLC4X_OPTIONS"]