Posts Tagged Pipeline

Virtual Development Server: Provide Docker images in docker registry for Oracle via Jenkins

This is a follow up to earlier Virtual Development Server: Provide Docker images in docker registry for Oracle XE Database and others.

We now try to automated build of all needed images as soon as Oracle GitHub Sources changed or we need to build our Vagrant VirtualBox again from scratch.

After we have already installed Jenkins we now install first some needed plugins.

After this we create our Jenkins pipeline via “New Item”.

Here is the script for the moment, later after we have it successfully tested and implemented all builds of images we need, we will put it in it’s own git repository and call it from there. The script is written in Pipeline Model Definition, a config-like syntax for defining Pipelines.

pipeline {
    agent label:'localhost_vagrant'
    stages {
        // Get the actual docker images sourcse from oracle git account
        stage('Get Sources') {
            steps {
                git url: 'https://github.com/oracle/docker-images.git'
            }
        }
        stage('Build Oracle Docker Images') {
            steps {
                parallel (
                    "Database XE 11.2.0.2" : {
                        dir('OracleDatabase/dockerfiles') {
                            // provide the downloaded source (via your oracle account) from the host
                            sh 'if [ ! -f 11.2.0.2/oracle-xe-11.2.0-1.0.x86_64.rpm.zip ]; then cp /software/Oracle/Database/oracle-xe-11.2.0-1.0.x86_64.rpm.zip 11.2.0.2/oracle-xe-11.2.0-1.0.x86_64.rpm.zip; fi'
                            // build the image
                            sh 'sudo ./buildDockerImage.sh  -v 11.2.0.2 -x'
                            // prepare the image for push to the local registry
                            sh 'docker tag oracle/database:11.2.0.2-xe localhost:5000/oracle/database:11.2.0.2-xe'
                            // push to the local registry
                            sh 'docker push localhost:5000/oracle/database:11.2.0.2-xe'
                        }
                    },
                    "WebLogic 12.2.1.2" : {
                        // server-jre is required for Weblogic
                        dir('OracleJava/java-8') {
                            // provide the downloaded source (via your oracle account) from the host
                            sh 'if [ ! -f server-jre-8u111-linux-x64.tar.gz ]; then cp /software/Oracle/Java/server-jre-8u111-linux-x64.tar.gz server-jre-8u111-linux-x64.tar.gz; fi'
                            // build the image
                            sh 'sudo ./build.sh'
                            // prepare the image for push to the local registry
                            sh 'docker tag oracle/serverjre:8 localhost:5000/oracle/serverjre:8'
                            // push to the local registry
                            sh 'docker push localhost:5000/oracle/serverjre:8'
                        }
                        dir('OracleWebLogic/dockerfiles') {
                            // provide the downloaded source (via your oracle account) from the host
                            sh 'if [ ! -f 12.2.1.2/fmw_12.2.1.2.0_wls_Disk1_1of1.zip ]; then cp /software/Oracle/WebLogic/fmw_12.2.1.2.0_wls_Disk1_1of1.zip 12.2.1.2/fmw_12.2.1.2.0_wls_Disk1_1of1.zip; fi'
                            // build the image
                            sh 'sudo ./buildDockerImage.sh -v 12.2.1.2 -g'
                            // prepare the image for push to the local registry
                            sh 'docker tag oracle/weblogic:12.2.1.2-generic localhost:5000/oracle/weblogic:12.2.1.2-generic'
                            // push to the local registry
                            sh 'docker push localhost:5000/oracle/weblogic:12.2.1.2-generic'
                        }
                    }
                )
            }
        }
        stage('Cleanup') {
            steps {
                // clean virtualbox
                sh 'docker rmi --force localhost:5000/oracle/database:11.2.0.2-xe'
                sh 'docker rmi --force oracle/database:11.2.0.2-xe'
                sh 'docker rmi --force localhost:5000/oracle/weblogic:12.2.1.2-generic'
                sh 'docker rmi --force oracle/weblogic:12.2.1.2-generic'
                sh 'docker rmi --force localhost:5000/oracle/serverjre:8'
                sh 'docker rmi --force oracle/serverjre:8'
            }
        }

    }
}

We can wait now the 15 min poll time or start the job manually.

After an “vagrant halt / vagrant up” you can control in your browser, that the created images are persistent in the local docker registry:

docker_registry_persistent

Here you find the source code for this blog.

Here you find more about the topic “Virtual Development Server”.

That’s it.

, , , , , , , , , ,

Leave a comment