Let's ship it

In this section, we will use Jenkins 2 and Docker to build the application and ship it to the cloud. The following diagram shows the continuous delivery process built with Jenkins:

Figure 15.6: The continuous delivery process with Jenkins

As you can see, Jenkins will manage the packaging, deploying, and triggering of the E2E testing, and then notify developers when the build completes. All these steps are streamlined inside the Jenkins Pipeline plugin. If you're not familiar with Jenkins Pipeline, you might want to check out Jenkins user handbook at https://jenkins.io/doc/book/pipeline. When a build succeeds, we can use another Jenkins job to manually trigger the deployment of the application to the production environment.

When we deploy the application to the staging/production environment, we will need to prepare AWS EC2 instances by installing the dependencies our application requires, for example, OpenJDK, GraphicMagicks, and so on. Once the EC2 instance is ready, we will install our application as a service, which we talked in the last chapter. Then we use the taskagile command service to start the application.

All these extra steps we just described might not seem like too much work at the moment. However, imagine that our application grows, and we have more dependencies. Since we will need to make sure the versions of those dependencies in all the environments are exactly the same, the preparation of the server instances could be a tedious and time-consuming task. It can also be easier for us to make mistakes during the preparation.

The following diagram shows an improved version of this process:

Figure 15.7: An improved continuous delivery process with Jenkins and Docker

As you can see, after building the package with the mvn clean package command, we will build a Docker image to wrap all the dependencies our application has inside of it and then ship the Docker image to different environments, in which we only need to execute the docker run command to start the Docker container and boot up the application. Much simpler and more efficient.

Let's use this approach to ship our application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.54.168