Windward Engines can be used in a variety of ways to fit with your specific use-case. This article will discuss how to containerize a custom solution using the Windward Java engine with Docker. With this method, it is simple to create your own custom implementation of the Java engine inside of a Docker container. Note that this guide assumes that you are using a Windows operating system, but this can be done on a Linux-based OS as well.
- Windows 10 64-bit: Home/Pro 2004 or higher, or Enterprise/Education 1909 or higher
- Docker Desktop installed, configured to use Linux Containers
- A valid license key for the Java Engine
Windward licensing exists for many different needs. There are Pros and Cons for each type of License. The FLEX license is meant to be used in automated management environments such as Container management systems, Azure services and Auto scaling virtual environments. If you are planning on hosting your application with the Java Engine with any of these types of environments, we highly recommend the purchase of a FLEX (per page) license instead of a PRO (per machine/instance) license.
This guide assumes that you have Docker Desktop installed and configured on your machine. If it is not, follow the Docker Desktop installation documentation here. To verify that your installation was successful, open a command prompt or Powershell window and run the command:
If it returns a list of arguments, then Docker is installed on your machine. Additionally, Docker must be configured to run Linux Containers to successfully containerize the Windward Java Engine. To check, right-click on the docker icon located in the hidden icons section of the Windows taskbar.
If the menu that appears says "Switch to Linux containers..." then Docker is configured to run Windows containers. If the menu says "Switch to Windows containers..." then Docker is configured to run Linux containers.
To begin, visit the Windward Samples github here and download the samples. Inside, you will find the BasicSql folder in Container Samples/Java Engine, which contains the files necessary for this guide.
Inside of the BasicSql folder, you will find the above files.
- data is the folder that contains our sample template that we will use to generate output from with the container
- src contains our custom implementation of the Java engine that we want to containerize
- Dockerfile is the Dockerfile that Docker uses to build the image for the container
- pom.xml is the Maven build file for our custom implementation
- WindwardReports.properties is the file that contains our configuration for the Java engine.
We'll begin with an overview of the BasicSql application. Aside from the code itself, located in the src folder, we are primarily interested in the WindwardReports.properties file. It handles our configuration of the Java engine, and in this case is used to simply inject our license key for the Java engine into our custom implementation. Open it with a text editor of your choice, and replace the
[[LICENSE KEY]] with your license key.
With your license key entered, the image is ready to be built, and a container can be created with that image. Prior to doing so, we will discuss our implementation in more detail. For that, open the pom.xml file with a text editor of your choice.
In order to keep our implementation simple, we will be using Maven to build our application. Maven allows for us to declare our dependencies in the dependency section, and it will ensure that the correct dependencies are installed and in the correct location for our application. In this case, the two dependencies that we need are WindwardReports, which is the Java engine, and the mssql-jdbc, which is the library which handles connecting to a SQL database. For more information on customizing a pom.xml file, please use the official Maven reference here.
The Dockerfile manages how Docker will build the image for the container. For this guide, Docker is going to start with the latest alpine Linux image, and then install the necessary build tools for our project. From there, Docker will create a directory on the image for our application, and copy all of the necessary files to build our project. Docker will then build the project, and then move the now built project over to the final image, and set our application as the entry point for the image. This means that when a container is created and ran from this image, it will automatically run our application and then exit once completed. If you want to play around with the container while it is running, you can comment out the final "ENTRYPOINT" line with the "#" symbol. Doing so will result in the container running without starting our application, allowing you to enter the container to view its file structure and run your own commands. For further information about Dockerfiles, please use Docker's official documentation here.
Now that you are familiar with what we need to build the image, its time to do so. With command prompt or Powershell, navigate to the root folder of the BasicSql project, where the Dockerfile is located. To build the image, run the command:
This command builds the image and names it 'windward-java-engine.' From here, the image is complete and you are ready to create a container with it!
To run the newly created docker image in a container, simply enter the following command in the same command prompt or Powershell that you used to create the image:
This command creates a Docker container named WindwardJavaEngine from the windward-java-engine, and runs the container. If the container was successfully ran, you should see the following output in your command prompt/Powershell window:
Now that the container has run, let's see the output from our template. This output is currently stored in the Samples folder on the Docker container, so in order to get it from the container, in your command prompt/Powershell window run the command:
with "path/to/destination" being the path to where you would like the output to go. Once the command has been run, you should have the newly generated output Report.pdf at the destination that you entered. If the container was successful, your Report.pdf should match the one located in the root directory of the BasicSql sample. And that's all! Congrats on successfully containerizing a custom implementation of Windward Studios' Java engine. For further information on creating your own implementation, the Java engine API is located here. <!--NEEDS LINK>