Creating Docker Image of Application

The step-by-step instructions on this page enable you to create a Docker image of the application that you built using the Canvas Technology platform.

These instructions are applicable for Tomcat server only. It is assumed that a Docker Container running on Linux environment is available for this procedure.

When a new application is created using the Canvas Technology Platform, that application’s project will contain folders as shown in the following screen shot. Here, let’s assume that the application name is Demo. You can notice in the screen shot that the folders are prefixed with the application name, e.g. DemoDBScripts, DemoLib etc.

Perform the following steps to enable docker build for your application:

  1. In the application project folder, open the build properties file (e.g. buildDemo.properties) and enable docker build as follows:

    BUILD_DOCKER_IMAGE = Y
  2. Perform this step if you are using Oracle database only. In the build properties file (e.g. buildDemo.properties), uncomment the following property:

    DB = oracle
  3. Open the ..\Docker_Dependencies\Dockerfile file and update as follows:


    Ensure to change the contents of Dockerfile according to your application name and work folder in the indicated places:

    FROM canvasintellect/tomcat COPY demo /usr/local/tomcat/webapps/demo #Note: Replace 'demo' with your application WAR name. COPY ./server.xml /usr/local/tomcat/conf COPY ./context.xml /usr/local/tomcat/conf COPY ./Demo /usr/local/Demo #Note: Here the work folder name is 'Demo', change it to your application work folder name. COPY ./initial.sh /usr/local/tomcat/ USER root EXPOSE 8080 RUN chown -R 1000370000:0 /usr/local/Demo \ && chmod -R og+rw /usr/local/Demo #Note: Change the user and grant permission for your application work folder. RUN chmod -R 777 /usr/local/Demo RUN chown -R 1000370000:0 /usr/local/tomcat/webapps/demo \ && chmod -R og+rw /usr/local/tomcat/webapps/demo #Note: Change the user and grant permission for your application WAR RUN chmod -R 777 /usr/local/tomcat/webapps/demo RUN chmod 777 /usr/local/tomcat/initial.sh USER 1000370000 ENTRYPOINT [ "/usr/local/tomcat/initial.sh"]
  4. Ensure that the contents of ..\Docker_Dependencies\docker-build.sh file are as follows:


    Contents of docker-build.sh file:

  5. If using MySQL schema, add the application datasource entries in the ..\Docker_Dependencies\mysql\server.xml and ..\Docker_Dependencies\mysql\context.xml files as follows:


    Entries in server.xml for MySQL. Here, since the application name is Demo, the Datasource names are DemoCanvasDataSource and DemoAppDataSource. Ensure to change these accordingly to your application’s datasource names:


    Entries in context.xml for MySQL. Here, since the application name is Demo, the Datasource names are DemoCanvasDataSource and DemoAppDataSource. Ensure to change these accordingly to your application’s datasource names:

  6. If using Oracle schema, add the application datasource entries in ..\Docker_Dependencies\oracle\server.xml and ..\Docker_Dependencies\oracle\context.xml files as follows:


    Entries in server.xml for Oracle. Here, since the application name is Demo, the Datasource names are DemoCanvasDataSource and DemoAppDataSource. Ensure to change these accordingly to your application’s datasource names:


    Entries in context.xml for Oracle. Here, since the application name is Demo, the Datasource names are DemoCanvasDataSource and DemoAppDataSource. Ensure to change these accordingly to your application’s datasource names:

  7. In the build.xml file and add the following codes under <target name="-buildDemo"> tag.

  8. In the build.xml file and add the following codes under <target name="-setProperties" depends="-setLocalBuildProps"> tag. Here, the application name is Demo. Ensure to replace it with your application name and the folder paths in the same case:

     

  9. In the build.xml file and add the following codes after <target name="-createChecksumReport"> tag. Here, the application name is Demo. Ensure to replace it with your application name and the folder paths in the same case:

     

  10. In the CanvasApplicationContext.json file in ..\Dependencies\canvas\CTResources.jar, add your application’s context root as follows. Here, the application name is Demo. Ensure to replace it with your application name in the same case:

  11. Ensure that the following JOTM related JARs are located in the ..\Demo\Dependencies\Supporting_Jars\Database_Drivers folder: