This is the fourth article in the blog series on what makes FlexDeploy a perfect fit for container native technologies:

Want to follow along in FlexDeploy? Check out our JumpStart Demo Lab configured with Oracle E-Business Suite. This is a pre-configured, friction-free environment in the cloud for you to try FlexDeploy with no set up, installation, or configuration.

Try the FlexDeploy Demo Lab

In this post I am going to show how FlexDeploy can leverage Serverless paradigm and use Fn Project functions in a build workflow.

Let’s consider a simple workflow like this:

The goal of this workflow is to build an Oracle Jet application, save the web folder to an artifact repository, build a docker image containing the Jet application and Nginx web server and push the docker image to Docker Hub registry.

The first step of the build workflow Build OJet Application is a Shell plugin operation which invokes an Fn function building an Oracle JET application, zipping the web folder and pushing the zip file to a Nexus repository.  The invocation of the function looks like this:

curl $FN_APP_URL/build -d "$NEXUS_USER $NEXUS_PWD $NEXUS_URL $FD_PROJECT_VERSION"

The build Fn function is going to be based on a docker image which we can build with the following Dockerfile:

# Create an image from a "builder" Docker image
# See http://adfpractice-fedor.blogspot.com/2018/04/building-oracle-jet-applications-with.html
FROM eugeneflexagon/ojetbuilder

# install zip 
RUN apt-get update
RUN apt-get install zip -y

# install git 
RUN apt install git-all -y


# copy into container a shell script performing the build
COPY build.sh /usr/local/bin/build.sh
RUN chmod +x /usr/local/bin/build.sh

ENTRYPOINT ["xargs","/usr/local/bin/build.sh"]

So, let’s build and push the image to Docker Hub:

docker build -t eugeneflexagon/ojetbuilderfn .
docker push eugeneflexagon/ojetbuilderfn

The image eugeneflexagon/ojetbuilderfn contains git client to fetch source code of the Jet application, OJET Cli to build the application and zip to archive the web folder (result of the build).  It also contains build.sh shell script which actually, builds, zips and pushes the archive to the Nexus repository:

#!/bin/bash

# Clone the source code
git clone https://github.com/eedorenko/ojetdevops.git

# Build the application
cd ojetdevops
ojet build

# Archive the web folder
zip -r web web/*

# Push the archive to Nexus
curl -v  -u $1:$2 --upload-file web.zip http://$3/nexus/content/repositories/snapshots/jet/$4/web.zip

The script accepts four parameters: Nexus username/password, Nexus url and project version to organize Jet archives in the Nexus snapshot repository nicely:

 

Having eugeneflexagon/ojetbuilderfn Docker image created we can define the build function which is invoked by Build OJet Application workflow step:

fn apps create ojetbuilder
fn routes create ojetbuilder /build eugeneflexagon/ojetbuilderfn:latest

The next step of the workflow Build Docker Image invokes Docker plugin operation buildImage to build a Docker image containing Oracle JET application and a web server:

The image is going to be built with the following Dockerfile:

# Create a Docker image which runs Jet application
# It contains Nginx on top of Alpine and our Jet appliction (web folder)
# This image is the result of the build and it is going to be stored in Docker Hub
FROM nginx:1.10.2-alpine
COPY web /usr/share/nginx/html
EXPOSE 80

The last step of the workflow Push Docker Image invokes Docker plugin operation pushImage to push the image to Docker Hub:

 

Having the image pushed to Docker Hub we can pull it and run the container locally:

docker run -it -p 8082:80 eugeneflexagon/ojetdevops:latest

And see the result at http://localhost:8082, or we can deploy the image to a K8s cluster with deploy function as it was described in the previous post.

 

That’s it!

Previous Post: FlexDeploy Loves Functions: Deploy Docker Containers with Fn Functions

Next Post: FlexDeploy is a Container: Run FlexDeploy as a Docker Container

Eugene Fedorenko

I have over 16 years of progressive experience in information technology with software design and development, testing and deployment of enterprise banking software. Graduated from Kharkiv Aviation Institute (Ukraine) in 1999 with a master's degree in computer science. I previously worked for CS Integra in Ukraine and for eProseed in the Netherlands, focusing on building enterprise solutions with Oracle ADF. Recently, I joined Flexagon and hold a position of Senior Architect. I have been recognized as an Oracle Certified Professional (OCP) and I am considered to be an expert in Oracle Fusion Middleware. I have been a speaker at various local and international IT conferences such as Oracle Day, Oracle OpenWorld, ODTUG Kscope, RMOUG Training Days, UKOUG and DOAG. I am an author at the ADF practice blog and a member of ADF Enterprise Methodology Group.

More posts by Eugene Fedorenko
  

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *