Containerization is a technology used in software packaging, enabling developers to bundle an application and its dependencies into a standardized package for deployment. Containers operate in isolation from each other and the underlying host system, which contributes to their lightweight and portable characteristics. Consequently, they are well-suited for deploying applications in cloud environments, where multiple containers can efficiently utilize shared resources.
Containerization in SAP Commerce Cloud offers a range of benefits when setting up applications on a local machine:
When comparing traditional setups with container-based setups on a local machine, several distinct differences emerge.
Environment Isolation:
Resource Utilization:
Dependency Management:
Development Environment Consistency:
Deployment Flexibility:
Isolation and Security:
In summary, container-based application setups in SAP Commerce Cloud offer several significant advantages over traditional setups on local machines. These include improved environment isolation, optimized resource utilization, simplified dependency management, consistent development environments, streamlined deployment flexibility, and enhanced security. These benefits make containerization an attractive option for local development workflows, particularly in modern software development environments.
This section focuses on two primary containerization tools: Docker and Podman.
Docker and Podman are both containerization technologies that facilitate the packaging and execution of applications within isolated environments. They adhere to the Open Container Initiative (OCI) standards, ensuring compatibility between container images created with one tool to be used with the other.
Below is a table summarizing the key features of Docker and Podman:
Choosing the Containerization Platform and Installation
The choice of a containerization platform depends on your specific needs and requirements:
· Docker: Ideal if you prioritize a mature, user-friendly containerization technology with extensive community support, a robust ecosystem of tools and resources.
· Podman: A great choice if you need a lightweight, secure containerization technology that is easy to manage.
We will be using docker for this example
Installing Docker on Linux (Ubuntu)
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo “deb [arch=$(dpkg –print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo “$VERSION_CODENAME”) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Download the latest DEB package
wget https://desktop.docker.com/linux/main/amd64/149282/docker-desktop-4.30.0-amd64.deb
Install the package with apt as follows:
sudo apt-get install ./docker-desktop-<version>-<arch>.deb
Installing Docker in Mac
Download the installer using the download buttons at the top of the page, or from the release notes(https://docs.docker.com/desktop/release-notes/).
Double-click Docker.dmg to open the installer, then drag the Docker icon to the Applications folder. By default, Docker Desktop is installed at /Applications/Docker.app.
Double-click Docker.app in the Applications folder to complete the Docker Installation.
Installing Docker in Windows
Download the installer using the download button at the top of the page, or from the release notes(https://docs.docker.com/desktop/release-notes).
Double-click Docker Desktop Installer.exe to run the installer. By default, Docker Desktop is installed at C:\Program Files\Docker\Docker.
When prompted, select WSL 2 or Hyper-V option on the Configuration page as per your choice of backend.
If your system only supports one of the two options, you will not be able to select which backend to use.
Follow the instructions on the installation wizard to authorize the installer and proceed with the installation.
A GitLab repository has been created with all the necessary files required to build Hybris version 2205.12, along with SOLR version 8.11 and MySQL DB version 8.0. Below is our target setup.
Before doing this setup, make sure your system or docker-machine has enough resources. I would recommend at least 100GB disk space, 4 CPUs and 8GB RAM allocated to Docker.
Clone the GitLab repository
git clone https://gitlab.com/neocloudops-public/hybris_container_project.git
NB:
Build DB, SOLR & Hybris Images and run containers
cd hybris_container_project
docker compose up -d –build
Containers will get built and will start automatically. Verify the container logs to confirm the services are up & running properly.
If you check the app-db container logs, you should see a line saying:
[Server] /usr/sbin/mysqld: ready for connections
If you check the app-solr container logs, you should see a line saying:
INFO (main) [ ] o.e.j.s.Server Started
If you check the app-hybris container logs, you should see a line saying:
INFO: Server startup in **** ms
Now let’s restart the containers (Maybe you will get some errors in container startup in the above step, restart will fix those issues),
docker compose down && docker compose up –d –build
Once containers are up,
Open http://localhost:8983/solr/#/ for SOLR Admin.
Open http://localhost:8985 for PHPMyAdmin. Give `host` as `app-db` & `username/password `as `hybris/hybris` to login.
Open https://localhost:9002/ for Hybris HAC. Do a system Initialization with default settings. Once it is finished, you will be able to log in to HAC as an Admin user using `admin/admin` credentials.
Open the below URL for the default electronic store:
https://localhost:9002/yacceleratorstorefront/electronics/en/?site=electronics&clear=true
So, what is happening here is when you execute docker-compose up –build, it looks at the configuration in docker-composer.yml. In that file, it’s specified to build an image for the Solr app, Db app & Hybris app containers. To do this, it reads the instructions from the Dockerfile located inside the app-solr, app-db & app-hybris directories respectively. This file contains all the steps needed to create the image, like installing software or setting configurations. There’s also a tool called phpMyAdmin included, which helps manage the database easily.
Once the images are created based on the instructions in these Dockerfiles, they are saved. Then, using the settings from docker-compose.yml, Docker creates and starts containers using these saved images.
Containerization technology offers developers a streamlined approach to setting up processes, enabling reproducible environments and accelerating development cycles.
By understanding the differences between traditional and container-based setups, developers can appreciate the benefits of adopting containerization for local application development. Containerization isolates applications and their dependencies within lightweight, portable containers, ensuring consistency and efficiency across different environments. For seamless setup of applications like SAP Commerce Cloud, SOLR, and MySQL on a local machine, developers can follow tailored steps for each application’s requirements. This approach creates self-contained environments that include all necessary dependencies, configurations, and services, ensuring smooth operation of the application stack on a local machine.
In practice, setting up containers for SAP Commerce Cloud, SOLR, and MySQL involves: · Creating Docker images for each application. · Defining Docker Compose configurations to manage container orchestration. · Ensuring proper networking and communication between containers.
With containerization, developers can seamlessly manage dependencies, scale applications, and replicate production environments locally, facilitating efficient development and testing workflows.
Ready to optimize your SAP Commerce Cloud setup? Contact PIT solutions for expert guidance on containerized development environments.