You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2019/07/11 09:35:54 UTC

[tomcat] branch master updated: Add example Dockerfile for native image

This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new eaf0a84  Add example Dockerfile for native image
eaf0a84 is described below

commit eaf0a846bf1014b24c6b750ee63f1eb9398c12aa
Author: remm <re...@apache.org>
AuthorDate: Thu Jul 11 11:35:42 2019 +0200

    Add example Dockerfile for native image
    
    More importantly, test it.
---
 res/tomcat-maven/DockerfileGraal | 40 ++++++++++++++++++++++++++++++++++++++++
 res/tomcat-maven/README.md       |  4 ++++
 res/tomcat-maven/tomcat.yaml     |  2 +-
 3 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/res/tomcat-maven/DockerfileGraal b/res/tomcat-maven/DockerfileGraal
new file mode 100644
index 0000000..b801aa3
--- /dev/null
+++ b/res/tomcat-maven/DockerfileGraal
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM busybox:glibc
+
+VOLUME /tmp
+
+USER root
+RUN mkdir -m 777 -p /deployments
+
+ADD tomcat-maven-1.0 /deployments/app
+ADD conf /deployments/conf
+ADD webapps /deployments/webapps
+
+WORKDIR /deployments
+
+ARG namespace=tomcat
+ENV KUBERNETES_NAMESPACE=$namespace
+ARG port=8080
+EXPOSE $port
+
+ENV JAVA_OPTS="-Dcatalina.base=. -Djava.security.egd=file:/dev/urandom"
+
+# Add JULI logging configuration
+ENV JAVA_OPTS="${JAVA_OPTS} -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=conf/logging.properties"
+
+ENTRYPOINT [ "sh", "-c", "/deployments/app $JAVA_OPTS" ]
diff --git a/res/tomcat-maven/README.md b/res/tomcat-maven/README.md
index 02ce071..b9e45a7 100644
--- a/res/tomcat-maven/README.md
+++ b/res/tomcat-maven/README.md
@@ -105,3 +105,7 @@ $JAVA_HOME/bin/native-image-configure generate --trace-input=$TOMCAT_MAVEN/targe
 $JAVA_HOME/bin/native-image --no-server --allow-incomplete-classpath --enable-https --initialize-at-build-time=org.eclipse.jdt,org.apache.el.parser.SimpleNode,javax.servlet.jsp.JspFactory,org.apache.jasper.servlet.JasperInitializer,org.apache.jasper.runtime.JspFactoryImpl -H:+JNI -H:+ReportUnsupportedElementsAtRuntime -H:+ReportExceptionStackTraces -H:EnableURLProtocols=jar -H:ConfigurationFileDirectories=$TOMCAT_MAVEN/target/ -H:ReflectionConfigurationFiles=$TOMCAT_MAVEN/tomcat-reflecti [...]
 ./tomcat-maven-1.0 -Djava.library.path=$JAVA_HOME/jre/lib/amd64 -Dcatalina.base=. -Djava.util.logging.config.file=conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
 ```
+
+Running in a container is possible, an example `DockerfileGraal` is given. To use a native image in a container that is not identical to the build platform,
+the `native-image` call will need to use the additional `--static` parameter to statically link libraries (this will then require zlib and glibc
+static libraries).
diff --git a/res/tomcat-maven/tomcat.yaml b/res/tomcat-maven/tomcat.yaml
index d890f61..9f115eb 100644
--- a/res/tomcat-maven/tomcat.yaml
+++ b/res/tomcat-maven/tomcat.yaml
@@ -18,7 +18,7 @@ spec:
     spec:
       containers:
       - name: tomcat
-        image: apache/tomcat:1.0
+        image: apache/tomcat-maven:1.0
         ports:
         - containerPort: 8080
         - containerPort: 8778


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org