Written by Vedarth Sharma, OMP intern
These past few weeks were full of excitement and learning for me. The goal of my project is to make docker images for s390x architecture in SUSE Linux Enterprise Server 15 and automate the scheduled build process for clefOS images. The first half of the project was to make the images. We initially planned to build the images for openSUSE, b. But openSUSE had not been kept current with s390x. That forced us to switch to SLES15 instead.
My first challenge was to build a base image of SLES15. The base image will then get used by all of the other images. This was a challenge for me as I had never built a base image before. To accomplish this, Neale, my mentor, provided me an instance of SLES15 linux guest. I accessed the vm and wrote a bash script that will create a chroot environment, add repos to it, install essential packages and finally make a tarball. This tarball will then get utilized by our Dockerfile which builds the base image using `FROM scratch`.
After achieving this goal, I moved on to building more images for SLES 15. Then came MEAN stack. The tech stack of Mongodb, Express, Angular and Nodejs is very popular and we wanted it to be a docker image for s390x base SLES15. But we couldn’t find any official mongodb package for SLES15. I tried using mongodb for SLES12, but it didn’t work as it was unable to find a package `libcrypto` even though it was installed. We finally decided that we will wait for an official release of mongodb for SLES15 before building an image for mongodb and mean stack.
The next phase of the project was building a system to automate the process of building the images so that the images can remain up to date. I achieved it by building a pipeline in Jenkins. The pipeline is scheduled to run once every month automatically every whenever a commit is made to the codebase or. The pipeline executes the appropriate commands to build all of the docker images. This feature allows us to evaluate if a change is breaking the image and pipeline is failing, thus adding CI/CD support to the repository. I am building a similar pipeline for all of the images of clefOS repository as well which will keep the images of clefOS up to date.
Building the pipeline was a challenging part in itself. Jenkinsfile can be used to run bash commands and if the Jenkins server has access to docker daemon building images is quite straightforward. But the problem is you cannot push those images. For that you will need to do docker login and provide credentials which is quite insecure. Here is where docker build plugin comes to the rescue. In a scripted Jenkinsfile this allows you to build a docker image by simply writing:-
app = docker.build“(repo/name”)
This allows us to use the app and push the images to dockerhub by utilizing the credentials plugin of jenkins. But this plugin has a major problem. It only works in the root directory Dockerfile. So when I had to implement a solution for this what I did was simply create an app for each of my docker image and then copy the dockerfile and dependency files to the root directory run docker.build command and move those files back and repeat the procedure for other files. This is the only working solution that I have found which builds the docker images and allows us to push them too from Jenkins itself.
I must say this has been a very challenging as well as rewarding project. Each day, I learn something new and I master it once I implement it a bunch of times. By working on s390x architecture based VMs, I have learnt how does a s390x system works. I am looking forward to working and finishing this project successfully.
Link to the code that I wrote :- https://github.com/openmainframeproject-internship/DockerHub-Development-Stacks