Deploy SAP HANA based Applications on docker Swarm...
Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
In first article we did installation of docker container, SAP HANA Express on docker container and OpenCart on HDB.
This article contains two parts:
Containerize Web Application
Deploy Web Application on Docker Swarm cluster
Again you have two options, you can see it in action in the below two videos or continue reading.
Icons courtesy draw.io and icon8.com
Icons courtesy draw.io and icon8.com
Since, you have opted to read, let's get started.
We will containerize standalone OpenCart installed earlier, so it can be deployed on Docker swarm cluster.
Let's resume from last article, the first step is to build a docker image so we can push to a repository for Docker Swarm use.
We need three things to build docker image for OpenCart, a base docker image, web-server and PHP. These requirements can fulfilled by using a single base image "php:7.4.13-apache-buster". It contains Debian as base OS, Apache as a web-server and PHP7.4.
Now all we need to do is create a docker build file. I will make it easy for you by positing my docker file below. All the scripts required for this article are available on my github repository https://github.com/sgomare
FROM php:7.4.13-apache-buster
COPY src/ /var/www/html/
RUN chmod 777 -R /var/www/html/opencart/
ENV APACHE_DOCUMENT_ROOT /var/www/html/opencart/upload
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
The docker build file contains a few instruction for the build, I will list only commands used above, but there are many commands available in docker build, for more information I would recommend you to refer docker documentation.
FROM : This is reference to base image from docker hub
COPY: Copy host directory in container at specified path, we will be copying everything installed at /var/www/html in host to same location in docker image. (for quick access I have made a copy of everything under /var/www/html to src/ directory where this Dockerfile is located)
RUN: This command runs a script in container in the build process.
We are using RUN command to update directory permissions and to install a few libraries required for PHP extensions along with actual PHP extensions.
Once we have Dockerfile all we need to do is run build command as follows to generate docker image :
docker build -t opencarthdb .
We will have a docker image at the end of build, we will push this docker image to docker hub repository as follows:
docker tag opencarthdb:latest <dockerhub_user>/<repository_name>:<tag>
That's it, we have successfully build OpenCart docker image to deploy on Docker Swarm cluster, refer above video for detailed instruction on Docker Swarm create, deploy and scale.
Next, we will deploy this docker image on Docker Swarm cluster using following command.
This will create docker service "cart" and deploy 3 instances of OpenCart on Docker Swarm cluster. We will be able to access cart on swarm hosts where these instance are active.
The cart instances can be scaled using following command:
docker service scale cart=12
In the end, we have different ways of using SAP HANA Express, we saw one possibility this series.
If you like this article, please feel free to share, tweet, like or follow me for new articles.