FROM registry.redhat.io/jboss-webserver-3/webserver31-tomcat8-openshift
# download from:
# https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.16/bin/apache-tomcat-9.0.16.tar.gz
ENV TOMCAT_VERSION 9.0.16
ARG TOMCAT_TGZ=apache-tomcat-${TOMCAT_VERSION}.tar.gz
# replace Tomcat
ENV CATALINA_HOME ${JWS_HOME}
ENV PATH ${JWS_HOME}/bin:$PATH
COPY ${TOMCAT_TGZ} /tmp/
RUN mv ${JWS_HOME} ${JWS_HOME}.tomcat8 && \
mkdir -p ${JWS_HOME} && \
tar -C ${JWS_HOME} --strip-components=1 -xf /tmp/${TOMCAT_TGZ} && \
chmod 755 ${JWS_HOME}
# rm -rf ${CATALINA_HOME}/webapps/* && \
RUN chmod -R 777 ${JWS_HOME}/*
RUN cd ${JWS_HOME}/conf && \
sed -i.bak -e 's/autoDeploy=".*$/autoDeploy="true" deployOnStartup="true">/' server.xml && \
grep -q 'deployOnStartup="true"' server.xml && echo "deployOnStartup added" && \
sed -i.bak -e '// reloadable="true">/' \
-e '/WatchedResource.*WEB-INF\/web.xml/a WEB-INF\/classes<\/WatchedResource>/' context.xml && \
grep -q 'reloadable="true">' context.xml && echo "reloadable set" && \
grep -q "WEB-INF/classes" context.xml && echo "WEB-INF/classes added" && \
(diff -c server.xml server.xml.bak;diff -c context.xml context.xml.bak;exit 0)
ENV JPDA_OPTS -agentlib:jdwp=transport=dt_socket,address=${JPDA_ADDRESS},server=y,suspend=n
CMD ["catalina.sh", "jpda", "run"]