cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Deploying H2 Docker versions quickly

No ratings

ThingWorx offers Docker based installations utilizing existing PostgreSQL databases. In newer releases ThingWorx Docker installers also offer using other databases.

 

Personally I'm using a certain method of deployment where I can just easily exchange some files, create new images and have a H2 based environment running for some quick tests.

 

As H2 is a built-in database, I will not dive into setting up the platform-settings.json for other connectivity. However other databases can be connected to by adjusting the platform-settings.json. This might also require an internal Docker Network structure which I will not elaborate on here.

 

Note: the following procedure is not fully supported as it's not using the deployment methods provided by the installers!

 

Create the Directory Structure

 

My Directory structure looks the following (expanded for the 8.2.x branch):

 

  • /home/ts/docker/
    • twx.8.0.x.h2
    • twx.8.1.x.h2
    • twx.8.2.x.h2
      • Dockerfile
      • settings
        • platform-settings.json
        • <license_file>
      • storage
      • Thingworx.war
    • twx.8.3.x.h2

 

I have a directory for every version I want to test with.

 

In each directory there's the Dockerfile - the recipe file I'm using.

There's also the version specific Thingworx.war file as well as two directories: settings and storage which I will map to the ThingWorx directories inside the image later.

 

The Recipe File

 

FROM tomcat:latest
MAINTAINER me@somewhere.com

LABEL version = "8.2.0"
LABEL database = "H2" 

RUN mkdir -p /ThingworxPlatform
RUN mkdir -p /ThingworxStorage
RUN mkdir -p /ThingworxBackupStorage

ENV LANG=C.UTF-8
ENV JAVA_OPTS="-server -d64 -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF-8 -Duser.timezone=GMT -XX:+UseNUMA -XX:+UseG1GC -Djava.library.path=/usr/local/tomcat/webapps/Thingworx/WEB-INF/extensions

COPY Thingworx.war /usr/local/tomcat/webapps

VOLUME ["/ThingworxPlatform", "/ThingworxStorage"]

EXPOSE 8080

 

I change the version label to keep track of the versions for each recipe.

 

Deploying

 

Build the Docker Image by navigating to the directory where the recipe file is based in

 

sudo docker build -t twx.8.2.x.h2 .

 

Create a Docker Container and start it

 

sudo docker run -d --name=twx.8.2.x.h2 -p 82:8080 -v /home/ts/docker/twx.8.2.x.h2/storage:/ThingworxStorage -v /home/ts/docker/twx.8.2.x.h2/settings:/ThingworxPlatform twx.8.2.x.h2

 

I change the name of the Image and the Container as well as the external port to distinguish all the different versions.

The -v option maps the paths in my Operating System to the paths in the Docker Container, so I can browse the ThingworxStorage and ThingworxPlatform folder without connecting inside the Container. That's quite handy to check the logs, or place the license file.

 

Starting and Stopping

 

I can fire up and shut down Containers I need with the following commands:

 

sudo docker start twx.8.2.x.h2
sudo docker stop twx.8.2.x.h2

 

What next

 

That's just my basic setup.

Usually I copy & paste a working directory for deploying another version and adjust what needs to be changed.

You could use this as a basis for quick and easy deployment where even additional features could be added, i.e. HTTPS configuration or auto-deploying certain ThingWorx Extensions via a REST API call.

 

To ensure starting with a clean Image, for building new Images I delete the contents of the storage folder and only leave the platform-settings.json in the settings folder (I copy the license later after generating it with my new Device ID).

Version history
Last update:
‎Jan 03, 2019 09:28 AM
Updated by:
Labels (2)