On this page

Some of the functionalities provided by Web Application Platform are long-running tasks that take longer time periods and machine resources to be executed. One notable example is exporting Cameo Collaborator documents to various formats (pdf, html) that is provided by the Document Exporter web application. It is possible to deploy such applications on a separate web container instance to withdraw load from the server where remaining web applications are deployed.

To make the solution scalable, you can use the Docker as the container platform to run web applications. For example, you can run a single instance of Web Application Platform applications on one Tomcat instance and run one or more instances of the Document Exporter as the Docker containers.


To run a Docker container


  1. Create a Dockerfile for a web application.
  2. Specify the external host/port information as the value of the service.uri parameter in the webappplatform.properties file. This host/port must be accessible from the outside of the Docker container (e.g., from a user‘s browser).
  3. If needed, run multiple instances of the web application simultaneously and manage them using, for example, container orchestration tools.


The following section provides an example how to create a container for the Document Exporter web application.


Creating a container for Document Exporter

This section provides an example how to create a container for the Document Exporter web application.


To create a container for Document exporter


  1. Prepare a Dockerfile for the Document Exporter with image build instructions. For simplicity, the webappplatform.properties file will be copied to the Tomcat classpath within the container.

    FROM tomcat:9-jdk16-openjdk
    ARG TOMCAT_HOME=/usr/local/tomcat
    
    COPY logback.xml ${TOMCAT_DIR}/shared/conf/
    COPY document-exporter.war ${TOMCAT_HOME}/webapps/
    COPY webappplatform.properties ${TOMCAT_HOME}/shared/conf/
    COPY templates.zip /tmp
    
    RUN sed -i "s|shared\.loader=*$|shared\.loader=\"\${catalina.base}/shared/conf\"|" ${TOMCAT_HOME}/conf/catalina.properties
    RUN unzip /tmp/templates.zip -d /tmp/templates && mv /tmp/templates/* ${TOMCAT_HOME}/shared/conf/ && rm /tmp/templates.zip
    
    EXPOSE 8080
    CMD ["catalina.sh", "run"]
  2. Put the following files in a single directory:
    • Dockerfile
    • document-exporter.war
    • logback.xml
    • webappplatform.properties
    • templates.zip that contains templates used during export
  3. Use the following command to build the Docker image:

    docker build --tag document-exporter .
  4. Run the container on port 8080 by executing the following command:

    docker run -p 8080:8080 document-exporter

To test that if Document Exporter is accessible, send a request to this address://<host>:8080/document-exporter. If the container runs and the application is successfully started, a 404 page should be displayed with a custom error text and image.


Scaling Document Exporter

This section does not cover a particular scaling method. You can choose it based on the infrastructure available and your own preferences. There are several ways to scale the containerized Document Exporter application:

  • If a container orchestration tool is used to run Docker containers, it will provide means to create multiple instances of the container and take care of their management.
  • You can create multiple containers manually and involve other network tools for management, e.g., a load balancer. 

You need to have sticky sessions for the scaling to work.


Fonts

When a document is exported to the pdf format, fonts are required to be installed on the OS where the document is being generated. If fonts installed on the OS and used for creating models and fonts of the deployment OS are different, you may need to install additional fonts. For example, if the deployment OS is Linux-based, and models are created using a Windows version of the modeling tool, then Microsoft true type fonts should be installed to have an expected output.

Microsoft True Type Fonts

General instructions describing how to add Microsft True Type fonts to the Linux-based OS are provided in the Exporting documents to PDF and HTML chapter. However, the installation of the fonts depends on the Docker container OS. Assuming that font files are pre-downloaded and put to the msttcore folder, this folder can be moved to the folder with the Dockerfile. Then you can copy fonts to the Linux font folder by using the following script:

Dockerfile example

FROM tomcat:9-jdk16-openjdk
ARG TOMCAT_HOME=/usr/local/tomcat

COPY logback.xml ${TOMCAT_HOME}/shared/conf/
COPY document-exporter.war ${TOMCAT_HOME}/webapps/
COPY webappplatform.properties ${TOMCAT_HOME}/shared/conf/
COPY templates.zip /tmp
COPY msttcore /usr/share/fonts/msttcore

RUN sed -i "s|shared\.loader=*$|shared\.loader=\"\${catalina.base}/shared/conf\"|" ${TOMCAT_HOME}/conf/catalina.properties
RUN unzip /tmp/templates.zip -d /tmp/templates && mv /tmp/templates/* ${TOMCAT_HOME}/shared/conf/ && rm /tmp/templates.zip
RUN fc-cache –f -v
EXPOSE 8080
CMD ["catalina.sh", "run"]