Alex,
Am 2020-01-10 12:47, schrieb Alex K:
Just to follow-up on this in case it will be useful to anyone, I
managed to
use also the official tomcat image. I had to amend my .war files and
use
the openjdk:8-jdk version instead of openjdk:11-jdk.
I have used the following Docker files to prepare my custom tomcat
image
(so as to have tomcat home at /opt/tomcat) and then deployed the final
app
as following:
Got openjdk:8-jdk Docker file from:
https://github.com/docker-library/tomcat/blob/807a2b4f219d70f5ba6f4773d4ee4ee155850b0d/8.5/jdk8/openjdk/Dockerfile
Amended the tomcat home to /opt/tomcat.
Then deployed the app using the following Docker file:
FROM tomcat:custom
USER root
ENV CATALINA_HOME /opt/tomcat
ENV PATH $CATALINA_HOME/bin:$PATH
RUN mkdir -p "$CATALINA_HOME"
WORKDIR $CATALINA_HOME
ADD iforms_files/app.war $CATALINA_HOME/webapps/
ADD iforms_files/orbeon.war $CATALINA_HOME/webapps/
ADD iforms_files/server.xml $CATALINA_HOME/conf/
ADD iforms_files/mariadb-java-client-2.4.1.jar $CATALINA_HOME/lib
ADD iforms_files/setenv.sh $CATALINA_HOME/bin/
EXPOSE 8443
CMD ["catalina.sh", "run"]
I also tried the alpine versions:
https://hub.docker.com/layers/openjdk/library/openjdk/8-jre-alpine3.9/images/sha256-ea81da311d33e052eeea34336018434bdc50596100f9c623193867faa291b284
by using the same Dockerfile (by pointing to the custom built image
FROM
tomcat:alpine) I was able to deploy same app successfully reaching
image
size 281MB instead of 660MB with the default tomcat image.
Almost perfect.
Now have a look at
https://tomcat.apache.org/tomcat-9.0-doc/introduction.html#CATALINA_HOME_and_CATALINA_BASE.
This way you don't have to change the installation directory.
set CATALINA_BASE to /opt/tomcat and deploy all your conf and webapp to
the directories underneath /opt/tomcat.
like this:
FROM tomcat:8-jdk8-openjdk-slim
#(slim saves you space)
ENV CATALINA_BASE /opt/tomcat
WORKDIR $CATALINA_BASE
RUN mkdir -p temp logs work webapps conf
ADD iforms_files/app.war $CATALINA_BASE/webapps/
ADD iforms_files/orbeon.war $CATALINA_BASE/webapps/
ADD iforms_files/server.xml $CATALINA_BASE/conf/
# you do need those:
ADD iforms_files/tomcat-users.xml $CATALINA_BASE/conf/
ADD iforms_files/web.xml $CATALINA_BASE/conf/
ADD iforms_files/mariadb-java-client-2.4.1.jar $CATALINA_BASE/lib
ADD iforms_files/setenv.sh $CATALINA_BASE/bin/
EXPOSE 8443
CMD ["catalina.sh", "run"]
optionally I'd recommend to change the user to tomcat (root is baaah)
...
RUN set -x \
&& groupadd tomcat \
&& useradd -g tomcat -s /usr/bin/nologin -m -d /home/tomcat tomcat \
&& chown -R tomcat:tomcat $CATALINA_HOME $CATALINA_BASE
USER tomcat
...
Imagesize is sth like 300MB. Unique size 18MB
HTH
Peter
<snip>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org