Dockerized applications are applications that are packed into a Docker image and stored on a Docker repository. These Docker images are used to provision applications along with the environment onto any of the application environment (QA/ Stage/ PROD). These Docker images are versioned and stored on Docker repository. Versioning of Dockerized applications helps in easy storage and access to multiple releases of the application.
Majorly there are two strategies for continuous deployments using dockerized application:-
a) Continuous Deployments using Environment Image
b) Continuous Deployments using Application Image
Let us understand both, one by one
Continuous Deployments using Environment Image
This approach involves building a docker image of the environment from the Dockerfile kept over the SCM along with the code. The image is then uploaded to the Docker repository from where it is used to spin up several spontaneous environments, such as test environment to execute the functional tests, staging/ pre-prod environment to deploy artifacts, and production environment to deploy products.
In case of changes in the environment specifications, a new environment image is built and corresponding Dockerfile is updated. Since the environment Dockerfile is maintained with the code on the SCM, any change to the Dockerfile results in building and uploading of new environment image to the Docker image repository.
This environment image is used to supply different environments on to which Jenkins/ CI-CD tool deploy the required application artifact (WAR/ EAR etc.) and application is deployed on the environment.
Continuous Deployments using Application Image (Recommended)
This approach involves building a docker image of the environment and then pack it with the application’s artifacts that are built leveraging the latest code pushed by the development team on to the SCM tool and then create an application Docker image using the existing image.
This application Docker image can now be used to achieve continuous deployment and set up environments such as QA, Staging, and PROD. The version of the application Docker image should be similar to the version of the build and release of the artifacts.
Creating Application’s Docker Image
Since continuous deployment using application image is the recommended method, it is important to know how to create the application’s Docker image. It is described below step-by-step.
- Create an ‘env’ Dockerfile to build images and keep it in the master branch so that it is accessible to other branches such as develop and feature branches.
- Check if the files have changed since the previous commit using “git diff” command.
Use the previous image if there are no changes else build the docker image from the feature/ develop branch and start a container from this image.
- Place the build artifact (WAR/ EAR) using a CI tool such as Jenkins into the running environment’s container. Then create the new Docker image along with the environment and build artifact.
The name of this application docker image will be
Where the tag is a three decimal point number “major.minor.build_number” example: [1.0.0] in case of a build from the feature branch.
Also, to easily identify the image, the name of the image shall be a four decimal point number “major.minor.build_number.hotfix_number” example: [22.214.171.124] in case of a build from develop branch, after the feature branch is merged into it for the application release.
Do refer SCM branching and merging strategy document to understand the concept of feature branches and develop branch and the SCM strategy.
- Add an additional tag to the latest image of the branch such as ‘latest_feature‘ in images created from the feature branch and ‘latest_develop‘ in images created from the develop branch.
- Upload the application image to the Docker repository.
Continuous deployment using Dockerized application is a very interesting subject. It promotes automation as it allows us to establish a pipeline to deploy the application the moment it is completely built. The combination of Jenkins and Docker make it convenient to version and store images and at the same time deploy them nonchalantly.
You too may employ both these awesome tools to automate the application development and deployment process. Let us know the result and your thoughts on the concept in the comments below.
That’s it from us, until next time!
- Securing Applications from Vulnerabilities Using Nexus
Developers need certain libraries/frameworks in their projects most of which can be downloaded from Maven Central. If, however, any file is absent from the central repository, developers have to fetch…
- Mobile App Development and Continuous Delivery – Introduction to Docker (1/7)
DevOps has changed the way application development is done and has significantly influenced mobile app development too! DevOps methodology help bridge the gap between development and operations within an organization,…
- Packaging Web Applications into Dockers, for AWS Containerized Deployments
Overview and Benefits Packing applications into Docker containers allows developer to quickly deploy an application with all its dependencies, which are bundled into a single container and deployed anywhere without…
- Optimizing Regression Testing to achieve Product Proficiency
Regression Testing is one of the most common words in the software testing world. In the current testing scenario no release is assumed to be complete without Regression Testing. We…
- Mobile App Development and Continuous Delivery – SonarQube (2/7)
The next step in the process of setting your Mobile DevOps environment is to get hold of your code quality. I prefer SonarQube in the DevOps tool chain to evaluate…
- Hadoop Cluster Verification (HCV)
Verification scripts basically composed of idea to run a smoke test against any Hadoop component using shell script. HCV is a set of artifacts developed to verify successful implementation of…