How to create a Continuous Delivery Pipeline for APEX via OCCS



 Hi in this Post I tell you how to integrate a CD Pipeline for APEX Applications with the Oracle Cloud Container Services.

First thing you need to know: It’s all about Docker and Wercker! If you are not familiar with Docker you shouldn’t read further in this post. First go to docker.com and read about Docker and pull and push some images from and into a repository (Hint: You get a free Docker repository! Awesome!! 😊). After this go and read about Wercker and deployment of Docker images.
So now, that you’re familiar with Docker, go and pull the image winkelsjan/apex5.1:cd. That’s our basic image you need to configure for your needs. The awesome news: You can configure it by set some environment variables. I will explain it in a minute. First let me tell you something about what’s included in the image, and what kind of dark magic you’re using.
The image includes some self-written Scripts to export and deploy APEX applications and a preconfigured ORCAS instance. ORCAS is an OpenSource tool to deliver database objects.
Further information about ORCAS on
http://opitzconsulting.github.io/orcas/.
First you want to configure your development environment. To be honest: I presume you already have a central or a local APEX instance up and running. But if you don’t, you will find an image to host a local apex instance in the repository as well. Nevertheless, we start with running the apex5.1:cd image. For doing so you need to pass some information as environment variables:










These are the essential information you need to pass to the image.  The line of code looks something like this:
docker run -it -e DBHOST=dev -e DBNAME=dev -e WORKSPACE=SAMPLEAPP -e APEXAPPID=100 -e APEXAPPNAME=sampleApp --link dev winkelsjan/apex5.1:cd
  After you entered this line of code you will be asked for some more information:





You can add this information also to the previous line of code if you are ok with writing the schema password in the command line. Then just add the variables to the line of code as shown above.
Now you should be able to export your APEX application including all supporting database objects. All you need to do is switch to the user ‘apple’ and run the script export_f<APPID>.sh . This script needs the password of the source schema as an input parameter.
After that you can build your basic delivery image. To do so just run the Docker image above again, but this time deliver the information of the target environment. In our case it’s another container in the Container Cloud Service, but it is also possible to deliver to a remote database if the connection is established.
So far so good. To realize the continuous delivery chain, you need the following tools:
-        A Github Repository (github.com)
-        A Docker-Repository (docker.com)
-        A Wercker Account (wercker.com)
With the image, you have downloaded a wercker.yml-file that gets important now. This file is responsible to build the final deploy image by using a Wercker pipeline. But first you need to create a Git Repository and connect your Wercker account with the git repo.  To do so just klick “Add application”. You find this in the top region of the page, klick the “+” symbol and then choose “Add Application”.
Then you get to the next page where you are asked for the git repository you want to connect. Here it is important to notice, that you will only find git repositories that are not yet connected with a Wercker pipeline.
When you have connected your git repository with Wercker, you are ready to customize the wercker.yml-file for your needs.
This is where your docker-repository jumps into the frame. In the file, you will find three regions (box, build, registry). Under the “box” region you declare in which repository Wercker will find the basic image. The build region declares which steps are executed to build the final deploy image. Important in this section is the internal/docker-push step. This declares in which docker repository the final image is to be pushed. What do you have to do here is to change the source and target docker repository and, in case you are using a private repository, provide some authentication information by adding some pipeline environment variables (USERNAME, PASSWORD).
So far so good. When you now export your APEX Application and push your changes in your github repository, Wercker will register this.  It will then pulls the basic image from the repository performs the steps declared in the wercker.yml file and pushes it back into the target repository. This image is now ready to depoy our APEX Application on the next run. Meaning, we just must run the image.
In my case I have declared two Services in the Oracle Cloud Container Services (OCCS) and wrapped them up as a Stack, as shown below.
For the APEX Service I have used my own apex5.1 image from the winkelsjan repository. For the sampleApplication Service I have used the final deploy image from the target repository. After this you can hit the deploy Button on the Stacks page.
The Database is deployed first and then the deployment image is about to deploy the APEX Application… and it fails. Why? Because, you must create the Workspace and the Schema on the target environment manually. It’s important, that the Workspace is named equal to the Name you delivered in the configuration of the deploy Image. I’m currently working on a good solution for this issue.
Nevertheless, when you created the Workspace and the Schema the image will deploy your APEX Application nice and smoothly. It will take something around two Minutes and your APEX Application is fully deployed.

I would like it, if you try it out, give some feedback either per E-Mail or in the comments below.
Thanks a lot!

Cheers Jan

Kommentare

Beliebte Posts aus diesem Blog

APEX Development Container