...
In the application project folder, open the build properties file (e.g. buildDemo.properties) and enable docker build as follows:
Code Block language text BUILD_DOCKER_IMAGE = Y
Perform this step if you are using Oracle database only. In the build properties file (e.g. buildDemo.properties), uncomment the following property:
Code Block language text DB = oracle
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:Code Block language bash FROM canvasintellect/tomcat COPY demo /usr/local/tomcat/webapps/demo #note: please change my#Note: warnameReplace 'demo' intowith your warnameapplication WAR name. COPY ./server.xml /usr/local/tomcat/conf COPY ./context.xml /usr/local/tomcat/conf COPY ./Demo /usr/local/Demo #note#Note: hereHere the mywork Workfolderfolder name is 'Demo', please change myit Workfolderto nameyour application into yourwork Workfolderfolder 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: #changeChange the user Andand Grantgrant permission for your application Workfolderwork 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 #change #Note: Change the user Andand Grantgrant permission for your application warfileWAR 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"]
Ensure that the contents of ../\Docker_Dependencies/\docker-build.sh file are as follows:
Contents of docker-build.sh file:Code Block language bash sudo docker build -t $2:$3 $1
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 entries 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:
Context.xml entries for MySQLCode Block language xml <Resource auth="Container" driverClassName="com.mysql.cj.jdbc.Driver" factory="org.objectweb.jotm.datasource.DataSourceFactory" maxactive="50" maxidle="25" maxwait="-1" name="jdbc/DemoCanvasDataSource" password="{db_pass}" type="javax.sql.DataSource" url="jdbc:mysql://{db_ip}:{db_port}/{db_schema}" username="{db_user}" /> <Resource auth="Container" driverClassName="com.mysql.cj.jdbc.Driver" factory="org.objectweb.jotm.datasource.DataSourceFactory" maxactive="50" maxidle="25" maxwait="-1" name="jdbc/DemoAppDataSource" password="{db_pass}" type="javax.sql.DataSource" url="jdbc:mysql://{db_ip}:{db_port}/{db_schema}" username="{db_user}" />
>
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:Code Block language xml <ResourceLink global="jdbc/DemoCanvasDataSource" name="jdbc/DemoCanvasDataSource" type="javax.sql.DataSource" /> <ResourceLink global="jdbc/DemoAppDataSource" name="jdbc/DemoAppDataSource" type="javax.sql.DataSource" />
If using Oracle schema, add the application datasource entries in ../\Docker_Dependencies/\oracle/\server.xml and ../\Docker_Dependencies/oracle/context.xml
server.xml entries for Oracle\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:Code Block language xml <Resource auth="Container" driverClassName="oracle.jdbc.OracleDriver" factory="org.objectweb.jotm.datasource.DataSourceFactory" maxactive="10" maxidle="10" maxwait="-1" name="jdbc/DemoAppDataSource" password="{db_pwd}" type="javax.sql.DataSource" url="jdbc:oracle:thin:@{db_ip}:{db_port}/{db_SIR}" username="{db_schema}" /> <Resource auth="Container" driverClassName="oracle.jdbc.OracleDriver" factory="org.objectweb.jotm.datasource.DataSourceFactory" maxactive="10" maxidle="10" maxwait="-1" name="jdbc/DemoCanvasDataSource" password="{db_pwd}" type="javax.sql.DataSource" url="jdbc:oracle:thin:@{db_ip}:{db_port}/{db_SIR}" username="{db_schema}" />
ContextEntries in context.xml entries for Oracle 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:Code Block language xml <ResourceLink global="jdbc/DemoCanvasDataSource" name="jdbc/DemoCanvasDataSource" type="javax.sql.DataSource" /> <ResourceLink global="jdbc/DemoAppDataSource" name="jdbc/DemoAppDataSource" type="javax.sql.DataSource" />
In the build.xml file and add the following codes under <target name="-buildDemo"> tag:.
Code Block language xml <!-- Step 4: Check to build the docker Image --> <antcall target="-check.dockerImage"/>
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:
Code Block language xml <property name="DEMO_DOCKER_FILE" value="${DEMO_SRC_HOME}/Demo/Docker_Dependencies/Dockerfile" /> <property name="DEMO_DOCKER_BUILD_FILE" value="${DEMO_SRC_HOME}/Demo/Docker_Dependencies/docker-build.sh" /> <property name="imagename" value="demo" />
In the build.xml file and add the following codes after <target name="-createChecksumReport"> code section tag. Here, the application name is Demo. Ensure to replace it with your application name and the folder paths in the same case:
Code Block language xml <target name="-check.dockerImage"> <if> equals arg1="${BUILD_DOCKER_IMAGE}" arg2="Y" /> <then> <echo> File Exists </echo> <antcall target="-check.Operating System"/> </then> <else> <echo> demoApplication warWAR file is not build properly. Please Buildbuild the demoapplication and try again to dockerize the demo<it.</echo> <antcall target="-createChecksumReport"> <param name="SOURCE_DIR" value="${DIST_ROOT}" /> </antcall> </else> </if> </target> <target name="-check.Operating System"> <condition property="is.windows"> <os family="windows"/> </condition> <condition property="is.unix"> <os family="unix"/> </condition> <if> <isset property="is.windows"/> <then> <echo>For Windows System Environment docker <echo>Docker image build process is not supported for Windows environment.</echo> <antcall target="-createChecksumReport"> <param name="SOURCE_DIR" value="${DIST_ROOT}" /> </antcall> </then> </if> <if> <isset property="is.unix"/> <then> <antcall target="-check.docker"/> </then> </if> </target> <target name="-check.docker"> <exec executable="docker" outputproperty="output"> <arg value ="-v"/> </exec> <if> <contains string="${output}" substring="Docker version"/> <then> <antcall target="-configchange"/> </then> <else> <echo> Please Installinstall Docker and Trytry again for building the docker image .</echo> <antcall target="-createChecksumReport"> <param name="SOURCE_DIR" value="${DIST_ROOT}" /> </antcall> </else> </if> </target> <target name="-configchange"> <unzip src="${DIST_ROOT}/demo.war" dest="${DIST_ROOT}/demo"/> <delete file="${DIST_ROOT}/demo.war"/> <unzip src="${DIST_ROOT}/demo/WEB-INF/lib/DemoResources.jar" dest="${DIST_ROOT}/change"/> <replace file="${DIST_ROOT}/change/DemoImplementation.properties" token="D:/Canvas/Demo" value="/usr/local/Demo"/> <if> <equals arg1="${DB}" arg2="oracle" /> <then> <replace file="${DIST_ROOT}/change/Demodatabaseconfig.properties" token="mysql" value="oracle"/> </then> </if> <jar destfile="${DIST_ROOT}/demo/WEB-INF/lib/DemoResources.jar" basedir="${DIST_ROOT}/change"/> <delete dir="${DIST_ROOT}/change"/> <jar destfile="${DIST_ROOT}/demo.war"> <fileset dir="${DIST_ROOT}/demo"> <include name="**/*.*" /> </fileset> </jar> <copy file="${DEMO_SRC_HOME}/Demo/Docker_Dependencies/mysql/server.xml" todir="${DIST_ROOT}"/> <copy file="${DEMO_SRC_HOME}/Demo/Docker_Dependencies/mysql/context.xml" todir="${DIST_ROOT}"/> <copy file="${DEMO_SRC_HOME}/Demo/Docker_Dependencies/mysql/initial.sh" todir="${DIST_ROOT}"/> <copy todir="${DIST_ROOT}/Demo" preservelastmodified="true" verbose="true"> <fileset dir="${DEMO_SRC_HOME}/Demo/ToBeCopiedOutside/"/> </copy> <if> <equals arg1="${DB}" arg2="oracle" /> <then> <delete file="${DIST_ROOT}/server.xml"/> <delete file="${DIST_ROOT}/context.xml"/> <delete file="${DIST_ROOT}/initial.sh"/> <copy file="${DEMO_SRC_HOME}/Demo/Docker_Dependencies/oracle/server.xml" todir="${DIST_ROOT}"/> <copy file="${DEMO_SRC_HOME}/Demo/Docker_Dependencies/oracle/context.xml" todir="${DIST_ROOT}"/> <copy file="${DEMO_SRC_HOME}/Demo/Docker_Dependencies/oracle/initial.sh" todir="${DIST_ROOT}"/> </then> </if> <antcall target="-build.dockerimage"/> </target> <target name="-build.dockerimage"> <copy file="${DEMO_DOCKER_FILE}" todir="${DIST_ROOT}"/> <chmod file="${DEMO_DOCKER_BUILD_FILE}" perm="777"/> <exec executable="${DEMO_DOCKER_BUILD_FILE}"> <arg value="${DIST_ROOT}"/> <arg value="${imagename}"/> <arg value="${buildVersion}"/> </exec> <delete file="${DIST_ROOT}/Dockerfile"/> <delete file="${DIST_ROOT}/initial.sh"/> <delete dir="${DIST_ROOT}/demo"/> <delete file="${DIST_ROOT}/server.xml"/> <delete file="${DIST_ROOT}/context.xml"/> <delete dir="${DIST_ROOT}/Demo"/> <antcall target="-createChecksumReport"> <param name="SOURCE_DIR" value="${DIST_ROOT}" /> </antcall> </target>
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:
Code Block language json { “contextRoot : “demo”, “applicationId : “DEMO”, “displayName” : “Demo”, “isService” : “N” },
Ensure that the following JOTM related JARs are located in the ..\Demo\Dependencies\Supporting_Jars\Database_Drivers folder: