Tomcat packed with xsltproc and XSLT files for manipulating server.xml and app context.xml config
10K+
This contains building scripts for Apache Tomcat with LibXSLT for XML configuration mangling. Supported Tomcat versions:
For context-based deployment, an ENV named DEPLOY_CONTEXT has to be defined to indicate your application.war name. If not, ROOT.war assumed.
For more information, please go to GitHub page at: https://github.com/myquartz/tomcat-libxslt/tree/main
You can change the listening port of the tomcat instance by the following ENV variables:
A context-based data source or a global-based data source will be added to context.xml or server.xml accordingly, based-on enviroment variables.
The following ENV variables to define a data source:
When defining these parameters (bold name must have), the will be created/updated to context.xml or server.xml look like:
<Resource
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
minIdle="0"
name="${DB_SOURCENAME} or ${GLOBAL_DB_SOURCENAME}" driverClassName="${DB_CLASS}"
url="${DB_URL}" username="${DB_USERNAME}" password="${DB_PASSWORD}"
maxActive="${DB_POOL_MAX}" initialSize="${DB_POOL_INIT}" maxIdle="${DB_IDLE_MAX}"
validationQuery="${DB_VALIDATION_QUERY}" />
This Realms is for Servlet/Application authentication by a table hosting at the data source. If a context-based/global data source created, the realm will be set to context-based or global/context DB_SOURCENAME accordingly.
The following ENV variables to define the realm:
When defining these parameters, the will be created/updated to context.xml or server.xml look like:
<Realm className="org.apache.catalina.realm.DataSourceRealm"
dataSourceName="${DB_SOURCENAME} or ${GLOBAL_DB_SOURCENAME}"
userTable="${REALM_USERTAB}" userNameCol="${REALM_USERCOL}" userCredCol="${REALM_CREDCOL}"
userRoleTable="${REALM_ROLETAB}" roleNameCol="${REALM_ROLECOL}"
allRolesMode="${ALL_ROLES_MODE}">
<!-- if REALM_ALGORITHM and REALM_INTERATIONS defined -->
<CredentialHandler className="org.apache.catalina.realm.MessageDigestCredentialHandler"
algorithm="${REALM_ALGORITHM}" interations="${REALM_INTERATIONS}"
saltLength="${REALM_SALT_LENGTH}" encoding="${REALM_ENCODING}"
/>
</Realm>
To build an image for the web application named booking.war in the container-based tomcat instance, your application lookup JNDI resource named "jdbc/ds" to access the MySQL Database. you can define a Dockerfile as:
FROM myquartz/tomcat-xslt:9-jdk11
#Download appropriate drivers from Maven
RUN curl -sSo /usr/local/tomcat/lib/mysql-connector-java-8.0.30.jar https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.30/mysql-connector-java-8.0.30.jar
#RUN curl -sSo /usr/local/tomcat/lib/postgresql-42.5.4.jar https://repo1.maven.org/maven2/org/postgresql/postgresql/42.5.4/postgresql-42.5.4.jar
ENV TOMCAT_HTTP_PORT=8088
EXPOSE 8088
ENV DEPLOY_CONTEXT=booking
ENV DB_SOURCENAME=jdbc/ds
ENV DB_CLASS=com.mysql.cj.jdbc.Driver
ENV DB_URL=jdbc:mysql://mysqldb:3306/dbname
ENV DB_USERNAME=db_username
ENV DB_PASSWORD=
COPY target/booking.war /usr/local/tomcat/webapps/booking.war
Build and run the image:
mvn package
docker build -t booking-app .
docker run -d -p 8088:8088 -e DB_URL=jdbc:mysql://your-db-server-ip:3306/dbname -e DB_USERNAME=you -e DB_PASSWORD=your-password booking-app
Now open http://localhost:8088/booking for demostration.
Content type
Image
Digest
sha256:e1f74874d…
Size
218.5 MB
Last updated
27 days ago
docker pull myquartz/tomcat-xslt:11-jdk21-temurin