Skip to Content
Technical Articles

#HelloWorld SAPUI5 meets Kubernetes – Containers

Background

Being an #ABAPer the environment did not matter much to us, all we needed was SE80. In last few years it has changed drastically, right from the way we do development to the environment where those developments will run. This is what pushed me in the direction to learn more about containers and understand how they are relevant to us. The intent of this blog series is to share those experiences and learnings with a hope it might help someone take the first steps. In this series of blog we will  deploy a Hello World SAPUI5 app to containers and spin up some nodes.

Image credits

What are containers and images?

The example app which we have taken is SAPUI5 Hello World application, let’s try to containerizr it. In order to run any app what we need is a server where this app can be hosted, let’s say nginx. So this server will host our application, we will bundle them together in container. Container is nothing but your application and its dependencies in our case SAPUI5 application and nginx server.

Okay so if a container is our app and dependencies what is docker then? Docker is more like a platform which help you in creating these containers. So first we define is, what all things we want to package together for example SAPUI5 app and a nginx server. This together is called an Image. Image is just like ABAP class. Then using docker commands we created instance of these images which is nothing but containers same like class instances.These images are reusable and you can extend them as per the needs in the same way create ABAP subclasses. These images are hosted centrally on a docker hub or can also be hosted privately.

Let’s build our first custom image and a server.

First of all we need to install docker our laptops please follow the step mentioned hereOnce we have our docker app up and running we will being by creating an image. Please note that we can create an image via docker file or via cli We will use cli use in our case. The docker file ideally contains all the instruction to be executed for example first create a server and then copy files as shown below.

FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf

Let’s create a base image with nginx server alpine version.

docker create --name helloworldui5 -p 80:80 nginx:alpine

Look at what all images are available including our nginx image.

docker images  

Now we have the base image with the container but it is in created state not active as can be seen below.

docker ps -a

 

Start our container.

docker start helloworldui5

 

So now we have nginx server running on port 80 as mentioned while creating the image.

What about our SAPUI5 Hello World app?

We are have downloaded the sample code from walkthrough. If we were using docker file we would have added an instruction to copy the file from host location to nginx server nginx:/usr/share/nginx/html/. But since we are creating everything from the CLI we will do it manually via below mentioned command. This will copy our hello world SAPUI5 app to the nginx server.

docker cp `pwd` helloworldui5:/usr/share/nginx/html/

 

So now we have our files also deployed to the container let’s check our app at port 80 and folder webapp. Bingo its working in a container.

So now we have our container up to date with everything we will now create an image as well as add a tag.

docker commit helloworldui5

Docker tag <imageid> helloworldui5

So now we have modified image which has hello world SAPUI5 application running in a single container, how do we publish to docker hub? The purpose of pushing it to docker hub is so that anyone can reuse it. We will be using the same docker image while demonstrating Kubernetes. Docker allows us to create containers but how do we manage all these containers effectively ,that is the talk for next blog. Let’s publish this image to docker hub.

Deploy the local image to Docker Hub

Go to Docker Hub and create a repository for the image as shown below.

 

Tag your local repository to remote as shown below in the cli and push to remote repo

docker tag helloworldui5:latest nabheetmadan/helloworldui5:1.0
docker push nabheetmadan/helloworldui5:1.0

 

Now we have the reusable images available to be used further. In the next blog where we will see how Kubernetes handles N number of these containers!

Be the first to leave a comment
You must be Logged on to comment or reply to a post.