Running PrizmDoc for Java on Docker
Below are two examples of how to run PrizmDoc® for Java in Docker. If you are running Docker on Linux, skip to the Examples section.
Preferably in production, you will run this image on a Linux based Docker host such as Debian or Ubuntu LTS. If you are using Docker on macOS or Windows, it is only recommended to run PrizmDoc for Java this way for evaluation purposes. The default configuration does not provide enough memory or proper permissions.
Table of Contents
- Running PrizmDoc for Java on Docker
- Table of Contents
- Minimum Requirements
- Evaluating PrizmDoc for Java Docker on Linux
- Evaluating PrizmDoc for Java Docker on macOS
- Evaluating PrizmDoc for Java Docker on Windows
docker run
Examples- Thread Timeout
- Docker Resource Allocation
- Port Mapping
- Volume Definitions
- Inspecting an Image
- Label Names
com.snowbound.docker.virtualviewer.base_image
com.snowbound.docker.virtualviewer.build_host
com.snowbound.docker.virtualviewer.ci_buildnumber
com.snowbound.docker.virtualviewer.product
com.snowbound.docker.virtualviewer.product_version
com.snowbound.docker.virtualviewer.rm_java_artifact_version
com.snowbound.docker.virtualviewer.vendor
com.snowbound.docker.virtualviewer.vv_java_commit_id
- Label Names
- Building Custom PrizmDoc for Java Images
Minimum Requirements
- A valid, non-expired,
slicense.json
file- If no license is loaded, every page will have the watermark
Snowbound Software Evaluation
.
- If no license is loaded, every page will have the watermark
- Preferably, a Linux VM running Docker. We support
Ubuntu 18.04 LTS
andUbuntu 20.04 LTS
. - At least 4 logical CPUs.
- At least 4 GB of memory (Preferably 8 GB if you plan to process large documents).
- At least 8 GB of disk space for PrizmDoc® for Java (Preferably 32 GB).
- Additional space for content will be dependent on your project requirements.
- Additional space for tomcat logs will be dependent on your logging strategy.
Evaluating PrizmDoc for Java Docker on Linux
This configuration will give you the best results. Go here to get started.
Evaluating PrizmDoc for Java Docker on macOS
The default resource allocations that Docker for macOS comes configured with is not quite enough to see PrizmDoc® for Java perform properly. Please make the following adjustments.
- Open Docker
Preferences
- Open the
File Sharing
tab and make sure that you can access the path that you have downloaded theslicense.json
to. By default it will be somewhere in/Users
which is already enabled. - Select the
Advanced
tab and adjustMemory
to4096MB
andCPUs
to at least2
. - Click
Apply
and wait for Docker to restart. - Go here to get started.
Evaluating PrizmDoc for Java Docker on Windows
Note about Docker on Windows in VMware
Note that Docker on Windows in a Virtual Machine such as VMware requires nested virtualization. Docker on Windows requires a Hyper-V VM to run Docker. We 100% guarantee that PrizmDoc® for Java will run unacceptable in this configuration if at all. If you need to evaluate PrizmDoc® for Java on a virtual machine, use a Linux distribution such as Ubuntu 20.04 LTS.
Configuring
The default resource allocations that Docker for Windows comes configured with is not quite enough to see PrizmDoc® for Java perform properly. Please make the following adjustments.
- Open Docker
Settings
- Select the
Shared Drives
tab and enable the drive where yourslicense.jar
and configuration files are located. LikelyC:\
- You will be prompted for your Windows credentials.
- Be aware that Docker on Windows mounts volumes over CIFS as
0777
ora+rwx
. This is not configurable and can have security implications. This is one reason why we do not recommend using Docker for Windows in production.
- In Docker for macOS open the
File Sharing
tab and make sure that you can access the path that you have downloaded theslicense.json
to. By default it will be somewhere in/Users
which is already enabled. - Select the
Advanced
tab and adjustMemory
to4096MB
andCPUs
to at least2
.- This option may not be required under WSL2
- Click
Apply
and wait for the Docker Hyper-V virtual machine to restart. - Go here to get started.
docker run
Examples
Below are a few examples of how to run PrizmDoc® for Java on Docker. Before running any example, be sure to do the following first
- Clone this repo to the machine you will run docker (or download the ZIP and extract it)
- Copy your
slicense.json
file into the newly createdclasses
directory.- Optionally set the license as an environmental variable. See example below.
Sample Handler
- Run
docker run -it -p 8080:8080 -v <PATH TO CLASSES>:/snowbound/classes snowbound/virtualviewer:5.15.0-latest
. - Open a browser to http://localhost:8080/virtualviewer.
License as Environmental Variable
- Run
docker run -it -p 8080:8080 --env SLICENSE="CONTENTS OF SLICENSE.JSON" snowbound/virtualviewer:5.15.0-latest
.- You will need to escape
"
as\"
and place the license within quotes. - Example:
export SLICENSE='{"SerialNumber":"1294a340-e3b2-4366-89b6-0fe71aae3ffb","Company":"Snowbound Software","OrderNumber":"Documentation","License_ExpirationDate":"10-20-2021","Maintenance_ExpirationDate":"10-20-2021","Products":["RasterMasterJava","VirtualViewerJava"],"LicenseType":"None","OEM":"","CanOEM":false},"rastermaster":{"Major":-1,"Minor":-1,"Formats":["standard","annotation","svg"]},"virtualviewer":{"Major":-1,"Minor":-1},"Signature":"BAoYP3sCpJGFVVDlhqRa6XKWZ9od0HK9ngiWFN9EMZjIftrgOrYm9SIy58HHabRwXE/Cr5ClQcILAjT03XJ0Ndedt253PLtJmjVSD/5YhFQgCk4H4WUhxE1llqY+wL5eD6qBa8ekKk6pD5jT/7hZQvTvY7bbcsgL/54ndZIII6kg51qkfVCmu/KNFsDULWn8FVI3eyJc/AUZK1cYpOFykvZxux4uCOeloMRspeKkV+tXvagP/P9E50AdvlvsdjYOsLY2YrVinyOGDEWlwWj/neT/TG0+Qr0quOnrt3MxnyPKKsy8y0AN/ysMGmHcSF1HOQi6wxgG2rn8tbJfZ/aqeQ=="}' docker run -it -p 8080:8080 --env SLICENSE=$SLICENSE snowbound/virtualviewer:5.15.0-latest
- You will need to escape
- Open a browser to http://localhost:8080/virtualviewer.
Custom Content Handler
- Copy your custom content handler
.jar
and required dependencies into the newly createdclasses
directory. - In the
WEB-XML
directory, edit the parametercontentHandlerClass
and replacecom.snowbound.contenthandler.example.FileContentHandler
with the classpath of your custom content handler. - Run
docker run -it -p 8080:8080 -v <PATH TO CLASSES>:/snowbound/classes snowbound/virtualviewer:5.15.0-latest
- Open a browser to http://localhost:8080/virtualviewer.
Thread Timeout
Some documents may hang or take a long time to process. The thread stuck detection threshold
by default is 600 seconds
and interruptThreadThreshold
default is -1
which disables the feature. See the reference below for more information.
Edit server.xml
Inside your server.xml
file, you should see a <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
block near the end. If it does not already exist, insert the example <Valve>
block between the <Host>
</Host>
blocks.
<!-- Use the StuckThreadDetectionValve to test how VV/RM handles thread interruption -->
<Valve className="org.apache.catalina.valves.StuckThreadDetectionValve"
threshold="55"
interruptThreadThreshold="56" />
Be sure to adjust threshold
and interruptThreadThreshold
durations to your desired durations. PrizmDoc® for Java will alert you when a document fails to process within the alloted time.
You will need to add the -v <PATH TO TOMCAT>:/snowbound/tomcat
argument to your docker run
.
Example
docker run -it -p 8080:8080 -v /home/dpowers/git/virtualviewer-tomcat9.0-jdk11-openjdk_v5.15.0/classes:/snowbound/classes -v /home/dpowers/git/virtualviewer-tomcat9.0-jdk11-openjdk_v5.15.0/tomcat:/snowbound/tomcat snowbound/virtualviewer:5.15.0-latest
Reference
https://tomcat.apache.org/tomcat-7.0-doc/config/valve.html#Stuck_Thread_Detection_Valve
Docker Resource Allocation
Until Java 9, the JVM did not recognize CPU or memory limits set by the container flags. In Java 10, memory limits are automatically recognized and enforced. This is why PrizmDoc® for Java is built and packaged with OpenJDK 11.
Docker Arguments
-m
or --memory=
- Memory Allocation
The maximum amount of memory the container can use. If you set this option, the minimum allowed value is 4m
(4 megabyte).
--cpus=
- Logical CPU core count
Specify how much of the available CPU resources a container can use. For instance, if the host machine has two CPUs and you set --cpus="1.5"
, the container is guaranteed at most one and a half of the CPUs.
Example
docker run -it -p 8080:8080 -v /home/dpowers/classes:/snowbound/classes --mount type=tmpfs,destination=/tmp
/vvcache -m 512m --cpus=1 snowbound/virtualviewer:5.15.0-latest
Reference
https://docs.docker.com/config/containers/resource_constraints/
https://blog.docker.com/2018/04/improved-docker-container-integration-with-java-10/
Port Mapping
PrizmDoc® for Java runs on tomcat on port 8080
inside the Docker container. The argument formatting is as follows -p host_port:container_port
or -p host_ip:host_port:container_port
. The host_ip
is only required if your Docker host is assigned multiple IP addresses.
Standard Mapping
To expose 8080
on the host side, use the -p 8080:8080
argument
Different Port
If you require a different port such as 8085
, use -p 8085:8080
Different IP and Different Port
If you need to bind to a specific IP address, use -p 10.20.30.40:8085:8080
Volume Definitions
Volumes are the preferred mechanism for persisting data generated by and used by Docker containers.
/snowbound/classes
Classes to be added to the PrizmDoc® for Java webapp
- Place
slicense.json
, custom content handlerJAR
, and any otherJAR
files that are required in the$CATALINA_HOME/webapps/virtualviewer/WEB-INF/lib
directory - Directories will be ignored and existing files in
lib
will not be overwritten - Example:
-v /home/dpowers/git/virtualviewer-tomcat9.0-jdk11-openjdk_v5.15.0/classes:/snowbound/classes
/snowbound/fonts
Additional fonts not provided by the tomcat image
- Place additional
ttf
files here -
They will be copied into
$CATALINA_HOME/webapps/virtualviewer/fonts
- Example:
-v /home/dpowers/git/virtualviewer-tomcat9.0-jdk11-openjdk_v5.15.0/fonts:/snowbound/fonts
/snowbound/js
Snowbound JS files
- Place custom JS files here.
- If possible, modifications should be made inside
user-config
first.
/snowbound/tomcat
Tomcat global configuration files
- Place custom server.xml file here
-
They will be copied into
$CATALINA_HOME/conf
- Example:
-v /home/dpowers/git/virtualviewer-tomcat9.0-jdk11-openjdk_v5.15.0/tomcat:/snowbound/tomcat
/snowbound/user-config
PrizmDoc® for Java user configurable CSS
and JS
files
- Place custom
CSS
andJS
files here - Files will be copied into
$CATALINA_HOME/webapps/virtualviewer/user-config
- Example:
-v /home/dpowers/git/virtualviewer-tomcat9.0-jdk11-openjdk_v5.15.0/user-config:/snowbound/user-config
/tmp/vvcache
The default PrizmDoc® for Java ehcache
location. Adding a tmpfs
mount point may improve performance in some use cases. If your PrizmDoc® for Java install is clustered, you may want to use Terracotta
to distribute your ehcache
across nodes. This topic is beyond the scope of this document.
-
If you edit the
ehcache.xml
file and change the path, be sure to change it here as well - Non-persistent Example:
--mount type=tmpfs,destination=/tmp/vvcache
- Persistent Example:
-v vvcache:/tmp/vvcache
/snowbound/WEB-INF
tomcat webapp configuration for PrizmDoc® for Java
- Place modified
ehcache.xml
andweb.xml
files inWEB-INF
- They will be copied to
$CATALINA_HOME/webapps/virtualviewer/WEB-INF
- Example:
-v /home/dpowers/git/virtualviewer-tomcat9.0-jdk11-openjdk_v5.15.0/WEB-INF:/snowbound/WEB-INF
Inspecting an Image
Docker images are labeled with various pieces of meta data at build time. To show this information, run docker image inspect <image_name>
and look for the Labels
section. When submitting bugs or issues with Accusoft, please attach the output of this command if possible.
Label Names
com.snowbound.docker.virtualviewer.base_image
- The image this Docker image was based
FROM
. - Example:
tomcat:9.0-jdk11-openjdk
com.snowbound.docker.virtualviewer.build_host
- The build host that created this Docker image.
- Example:
sb0011qad-debian
com.snowbound.docker.virtualviewer.ci_buildnumber
- The
virtualviewer-dockerfiles
CI job number. - Example:
345
com.snowbound.docker.virtualviewer.product
- The specific flavor of PrizmDoc® for Java.
- Example:
virtualviewer-vanilla
,virtualviwer-alfresco
com.snowbound.docker.virtualviewer.product_version
- The PrizmDoc® for Java version number. The 4th number is the PrizmDoc® for Java-Java CI job number.
- Example:
5.15.0.345
com.snowbound.docker.virtualviewer.rm_java_artifact_version
- The artifact version of RasterMaster Java used in this PrizmDoc® for Java build.
- Example:
20.15.0
com.snowbound.docker.virtualviewer.vendor
- The image vendor name. It is strongly encouraged that you change this if you redistribute custom images via a registry.
- Example:
Accusoft Corporation
com.snowbound.docker.virtualviewer.vv_java_commit_id
- The GitHub PrizmDoc® for Java GitHub commit ID used when building the PrizmDoc® for Java
WAR
file. - Example:
ed84f77ae71f9671d60600e6c7403caf33f35ac4
Building Custom PrizmDoc for Java Images
This information is only for end users looking to build custom images. If you require further assistance, please contact Accusoft support for more information.
We currently build our image FROM tomcat:9.0-jdk11-openjdk
. You can find the official tomcat images at https://hub.docker.com/_/tomcat. If you need to build PrizmDoc® for Java from a different image, please visit our public GitHub repository. There you can find the Dockerfile
we use to build ours.
You will need a virtualviewer.war
package to build this image.
https://github.com/SnowboundSoftware/virtualviewer-dockerfiles-library
Have questions, corrections, or concerns about this topic? Please let us know!