Oracle WebLogic Image Tool
Posted by Dirk Nachbar on Friday, June 21, 2019
As I am currently working mainly with Oracle Products on Docker (Oracle Databases, Oracle JDK's and Oracle WebLogic Servers) I had a quick look on the Oracle WebLogic Image Tool https://github.com/oracle/weblogic-image-tool
This utility provided by Oracle is creating for you Docker Images of Oracle WebLogic Servers, downloads Patches directly from My Oracle Support and applying these patches into your Docker Image.
What you will need to do, at first get the Oracle WebLogic Image Tool from GitHub, and build the project with Maven, take note that you need to create upfront the build a cache directory under $HOME !
As next modify the imagetool-1.0.1-SNAPSHOT/bin/setup.sh script and add your JAVA_HOME
Now we can add the required Oracle JDK 1.8 software and the Oracle WebLogic Server installation software to the imagetool cache. The Oracle JDK 1.8 and Oracle WebLogic Server installation software you will need to download upfront and transfer them to your target server.
Now as we have added the required installation software to the imagetool cache we can start to create our image.
Just create under imagetool-1.0.1-SNAPSHOT/bin a new Shell script called create-wls-image.sh with following content and align the JAVA_HOME variable to your environment and the path to the imagetool lib directory. On top set the --tag to your desired Image Name
Now we can start to create our Docker Image
Lets check.
As you can see, the imagetool added the latest PSU for our Oracle WebLogic Server 12.2.1.3.0 and the OPatch Patch, so that when we build the next image, these patches are already added to the cache and don't need to be downloaded again. The only minor problem which I see, is the key value for the latest PSU is just given with "null_12.2.1.3.0", my personal wish would be, that Oracle is displaying instead of the "null" the Patch Number.
You can even use this utility in an "Offline-Mode" with no internet connection, you just need to download upfront the required patches from My Oracle Support and transfer them to your server and add them manually into the imagetool cache.
This utility provided by Oracle is creating for you Docker Images of Oracle WebLogic Servers, downloads Patches directly from My Oracle Support and applying these patches into your Docker Image.
What you will need to do, at first get the Oracle WebLogic Image Tool from GitHub, and build the project with Maven, take note that you need to create upfront the build a cache directory under $HOME !
# # Clone the Oracle WebLogic Image Tool from GitHub $ git clone https://github.com/oracle/weblogic-image-tool.git Cloning into 'weblogic-image-tool'... remote: Enumerating objects: 303, done. remote: Counting objects: 100% (303/303), done. remote: Compressing objects: 100% (169/169), done. remote: Total 2339 (delta 117), reused 243 (delta 81), pack-reused 2036 Receiving objects: 100% (2339/2339), 410.24 KiB | 1.24 MiB/s, done. Resolving deltas: 100% (985/985), done. # Create the required cache directory under $HOME $ mkdir $HOME/cache # Build the project with Maven $ mvn clean package . . . . . . [INFO] [INFO] --- maven-jar-plugin:3.1.1:jar (default-jar) @ imagetool --- [INFO] Building jar: /work/projects/weblogic-image-tool/imagetool/target/imagetool.jar [INFO] [INFO] --- exec-maven-plugin:1.6.0:exec (generate-autocompletion-script) @ imagetool --- [INFO] [INFO] --- maven-assembly-plugin:2.2-beta-5:single (build-zip-installer) @ imagetool --- [INFO] Reading assembly descriptor: src/assembly/zip.xml [INFO] Building zip: /work/projects/weblogic-image-tool/imagetool/target/imagetool-1.0.1-SNAPSHOT.zip [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] Build Tools 1.0 .................................... SUCCESS [ 0.789 s] [INFO] WebLogic Image Tool (parent) 1.0.1-SNAPSHOT ........ SUCCESS [ 0.001 s] [INFO] WebLogic Image Tool 1.0.1-SNAPSHOT ................. SUCCESS [ 4.835 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5.742 s [INFO] Finished at: 2019-06-21T09:17:03+02:00 [INFO] ------------------------------------------------------------------------ # Copy and extract the packaged Oracle WebLogic Image Tool to your target destination $ mkdir -p /work/tools $ cp imagetool/target/imagetool-1.0.1-SNAPSHOT.zip /work/tools $ cd /work/tools $ unzip imagetool-1.0.1-SNAPSHOT.zip $ cd imagetool-1.0.1-SNAPSHOT $ tree . ├── bin │ ├── logging.properties │ └── setup.sh └── lib ├── commons-codec-1.10.jar ├── commons-logging-1.2.jar ├── fluent-hc-4.5.6.jar ├── httpclient-4.5.6.jar ├── httpcore-4.4.10.jar ├── httpmime-4.5.6.jar ├── imagetool_completion.sh ├── imagetool.jar ├── json-20180813.jar └── picocli-3.8.0.jar 2 directories, 12 files
As next modify the imagetool-1.0.1-SNAPSHOT/bin/setup.sh script and add your JAVA_HOME
# # Align the bin/setup.sh with the required JAVA_HOME, must be a JDK 1.8 # Add just below the line "umask 27" a line with your JAVA_HOME $ vi bin/setup.sh . . . umask 27 export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_211 . . .
Now we can add the required Oracle JDK 1.8 software and the Oracle WebLogic Server installation software to the imagetool cache. The Oracle JDK 1.8 and Oracle WebLogic Server installation software you will need to download upfront and transfer them to your target server.
# # Assuming that you have downloaded and transferred already the installation software # to your target server, e.g. /work/software $ ls /work/software/ fmw_12.2.1.3.0_wls_Disk1_1of1.zip jdk-8u211-linux-x64.tar.gz # Source the setup.sh script $ cd /work/tools/imagetool-1.0.1-SNAPSHOT/bin $ . ./setup.sh # Adding Oracle JDK 1.8.0_211 to the Oracle WebLogic Image Tool cache $ imagetool cache addInstaller --type jdk --version 8u211 --path /work/software/jdk-8u211-linux-x64.tar.gz # Adding Oracle WebLogic Server 12.2.1.3.0 to the Oracle WebLogic Image Tool cache $ imagetool cache addInstaller --type wls --version 12.2.1.3.0 --path /work/software/fmw_12.2.1.3.0_wls_Disk1_1of1.zip # Check the content of the imagetool cache $ imagetool cache listItems Cache contents cache.dir=/home/din/cache jdk_8u211=/work/software/jdk-8u211-linux-x64.tar.gz wls_12.2.1.3.0=/work/software/fmw_12.2.1.3.0_wls_Disk1_1of1.zip
Now as we have added the required installation software to the imagetool cache we can start to create our image.
Just create under imagetool-1.0.1-SNAPSHOT/bin a new Shell script called create-wls-image.sh with following content and align the JAVA_HOME variable to your environment and the path to the imagetool lib directory. On top set the --tag to your desired Image Name
#!/bin/sh export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_211 export PATH=$JAVA_HOME/bin:$PATH alias imagetool='java -cp "/work/tools/imagetool-1.0.1-SNAPSHOT/lib/*" com.oracle.weblogic.imagetool.cli.CLIDriver' imagetool create \ --tag=oracle/wls:1.0 \ --fromImage=oraclelinux:7-slim \ --jdkVersion=8u211 \ --latestPSU \ --version=12.2.1.3.0 \ --type=wls \ --user=<Your MyOracleSupport UserAccount> \ --password=<Your MyOracleSupport Password> # Cleanup dangling images echo " ***********************************" echo " Cleanup dangling images" echo " ***********************************" docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
Now we can start to create our Docker Image
# $ chmod +x create-wls-image.sh $ ./create-wls-image.sh Jun 21, 2019 9:51:34 AM com.oracle.weblogic.imagetool.cli.menu.CreateImage call INFO: tmp directory used for build context: /home/din/wlsimgbuilder_temp770248339375336616 Jun 21, 2019 9:51:35 AM com.oracle.weblogic.imagetool.cli.menu.CreateImage call INFO: tmp directory for docker run: /home/din/wlsimgbuilder_temp8049214846342972141 Jun 21, 2019 9:51:36 AM com.oracle.weblogic.imagetool.cli.menu.CreateImage lambda$call$0 INFO: ID="ol" Jun 21, 2019 9:51:36 AM com.oracle.weblogic.imagetool.cli.menu.CreateImage lambda$call$0 INFO: VERSION_ID="7.6" Jun 21, 2019 9:52:48 AM com.oracle.weblogic.imagetool.cli.menu.CreateImage call INFO: docker cmd = docker build --force-rm=true --no-cache --tag oracle/wls:1.0 --build-arg WLS_PKG=fmw_12.2.1.3.0_wls_Disk1_1of1.zip --build-arg JAVA_PKG=jdk-8u211-linux-x64.tar.gz --build-arg BASE_IMAGE=oraclelinux:7-slim --build-arg PATCHDIR=patches /home/din/wlsimgbuilder_temp770248339375336616 Sending build context to Docker daemon 1.108GB . . . . . . Removing intermediate container f37f08f14b51 ---> 067e69f6d893 Successfully built 067e69f6d893 Successfully tagged oracle/wls:1.0 *********************************** Cleanup dangling images *********************************** . . . . . . Deleted: sha256:64ad73b32a2b8912c122fede17be996843f570999e74faec5a6bacafa4932714
Lets check.
# $ docker images | grep oracle/wls oracle/wls 1.0 067e69f6d893 3 minutes ago 1.48GB # Lets check the cache content of the Oracle WebLogic Image Tool $ imagetool cache listItems Cache contents cache.dir=/home/din/cache jdk_8u211=/work/software/jdk-8u211-linux-x64.tar.gz null_12.2.1.3.0=/home/din/cache/p29016089_122130_Generic.zip wls_12.2.1.3.0=/work/software/fmw_12.2.1.3.0_wls_Disk1_1of1.zip 28186730_opatch=/home/din/cache/p28186730_139400_Generic.zip
As you can see, the imagetool added the latest PSU for our Oracle WebLogic Server 12.2.1.3.0 and the OPatch Patch, so that when we build the next image, these patches are already added to the cache and don't need to be downloaded again. The only minor problem which I see, is the key value for the latest PSU is just given with "null_12.2.1.3.0", my personal wish would be, that Oracle is displaying instead of the "null" the Patch Number.
You can even use this utility in an "Offline-Mode" with no internet connection, you just need to download upfront the required patches from My Oracle Support and transfer them to your server and add them manually into the imagetool cache.
Categories: Docker, Oracle WebLogic Server 12c