Skip to content

Alfresco/alfresco-docker-base-tomcat

Repository files navigation

Alfresco Docker Base Tomcat Build Status Docker Hub Pulls

This repository provides the base Docker images for Tomcat 10.1.x and 9.0.x that are meant to be used within the Alfresco engineering to build Docker images for Java/Tomcat applications.

This image relies on the alfresco-docker-base-java image.

Flavours

Choose between one of the available flavours built from this repository:

Tomcat version Java version OS Image ref Size
9 11 Rocky Linux 8 alfresco/alfresco-base-tomcat:tomcat9-jre11-rockylinux8 tomcat9-jre11-rockylinux8 size
9 17 Rocky Linux 8 alfresco/alfresco-base-tomcat:tomcat9-jre17-rockylinux8 tomcat9-jre17-rockylinux8 size
10 11 Rocky Linux 8 alfresco/alfresco-base-tomcat:tomcat9-jre11-rockylinux8 tomcat10-jre11-rockylinux8 size
10 17 Rocky Linux 8 alfresco/alfresco-base-tomcat:tomcat10-jre17-rockylinux8 tomcat10-jre17-rockylinux8 size
10 17 Rocky Linux 9 alfresco/alfresco-base-tomcat:tomcat10-jre17-rockylinux9 tomcat10-jre17-rockylinux9 size

The images are available on:

  • Docker Hub, image name: alfresco/alfresco-base-tomcat
  • Quay (enterprise credentials required), image name: quay.io/alfresco/alfresco-base-tomcat

Image pinning

The pinning approach provided in alfresco-base-java is highly suggested for this image too.

Image customization

This image's Dockerfile is extensively using multi-stage builds to allow for customization of the image. The build process can be represented as shown in the diagram below:

flowchart TB

classDef custom fill:lightgrey,color:black,stroke:darkgrey,stroke-width:2px,stroke-dasharray: 5 5

subgraph Tomcat configuration process
debian(Debian 12 slim image)
tomcat_dist(Tomcat configurator image)
end

subgraph Tomcat Native library compilation
tcnative_build-rocky(tomcat native libs\nRockyLinux build image)
tcnative_build-mydistro(Add your distribution image\nwith tcnative build env):::custom
tcnative_build(tomcat native libs build env)
end

subgraph Java & APR enabled distrbution image
apr_pkg-rocky(RockyLinux image\nwith APR)
apr_pkg-mydistro(Add your distribution image\nwith APR):::custom
end

jbase(JAVA base image)
tomcat(Tomcat base image)

debian --> tomcat_dist
tomcat_dist ==> tomcat

jbase --> apr_pkg-rocky & apr_pkg-mydistro --> tomcat

jbase --> tcnative_build-rocky & tcnative_build-mydistro --> tcnative_build
tcnative_build ==> tomcat
Loading

Customizing the Tomcat configuration

To customize the Tomcat configuration, you can directly modify the tomcat_dist image build. This step leverage a debian image to download, check & configure the Tomcat distribution. By default the tool xmlstarlet is used to modify xml files (e.g. conf/server.xml) file so you can reuse it to apply your own changes. Should you need more tools, you can add them in the using the apt-get install command. As this is a multi-stage build, the tools installed in the tomcat_dist image are not present in the final image.

We recommend that configuration applied in this image is generic and not related to a single web application. A configuration change related to a specific web application should be done in the web application image.

Using a different base distribution/image

This project lets you use a different base distribution/image to create your Alfresco Tomcat base image. To do that you need to create additional, distro specific, stages in the multi-stage build and name them according to the build arguments you want to use at build time.

Base image requirements

The base image you want to use to build the Alfresco Tomcat base image must match the following requirements:

  • Provide a compatible and up-to-date Java Runtime Environment (JRE) version (for production we using JRE over JDK) as per the Alfresco compatibility matrix

Specifying the new base image

In addition to the build arguments documented in the build time, you need to tell the build process where the java base image can be found (if it's not present on the Alfresco image registry). The following build arguments are available:

  • IMAGE_JAVA_REPO: the repository where the base image can be found (default is quay.io/alfresco)
  • IMAGE_JAVA_NAME: the name of the base image to use (default is alfresco-base-java)
  • IMAGE_JAVA_TAG: the tag of the base image to use (default is jre${JAVA_MAJOR}-${DISTRIB_NAME}${DISTRIB_MAJOR})

Implementing Tomcat native libs build stage

You'll need to create a new stage in the Dockerfile that will be used to build the Tomcat native libraries. This stage should be named tcnative_build-<DISTRIB_NAME> where <DISTRIB_NAME> is the name of the distribution you want to use. Take a look at the existing tcnative_build-rockylinux stage for an example, but overall the goal is to install on your target distribution the required packages to build the Tomcat native libraries in the /usr/local/tcnative directory, so it can be copied to the final image.

For example:

FROM debian:bullseye-slim AS tcnative_build-ubuntu
...

Implementing APR enabled Tomcat base stage

This stage is pretty simple, you just need to install the APR package on your distribution. This stage should be named apr_pkg-<DISTRIB_NAME> where <DISTRIB_NAME> is the name of the distribution you want to use.

Development

Naming specs

The images built from this repository are named as follow:

tomcat<TOMCAT_VERSION>-<JAVA_DISTRIBUTION_TYPE><JAVA_MAJOR_VERSION>-<OS_DISTRIBUTION_NAME><OS_DISTRIBUTION_VERSION>

How to build an image locally

To build this image, run the following script:

IMAGE_REPOSITORY=alfresco/alfresco-base-tomcat
docker buildx build -t $IMAGE_REPOSITORY . \
  --build-arg DISTRIB_NAME=$DISTRIB_NAME \
  --build-arg DISTRIB_MAJOR=$DISTRIB_MAJOR \
  --build-arg JAVA_MAJOR=$JAVA_MAJOR \
  --build-arg TOMCAT_MAJOR=$TOMCAT_MAJOR \
  --no-cache

where:

  • DISTRIB_NAME is rockylinux
  • DISTRIB_MAJOR is 8 or 9 for rockylinux
  • JAVA_MAJOR is 11 or 17 for rockylinux only
  • TOMCAT_MAJOR is 8 or 9

Release

New images are built automatically on each new commit on master and on a weekly schedule.

Downstream projects