Continuous Deployment Of Web Applications With Jenkins And Docker on Cloud

In this tutorial we are going to learn continuous deployment of Web applications with Jenkins and Docker on Cloud servers.

Configuring Jenkins & Installing the Plugin Dependencies

In case you have already have jenkins downloaded, but not sure how to utilize it, no worries, we will go through it. Possibilities are you have a WAR/JAR file at present. Begin Jenkins by running the given command:

java -jar jenkins.war -httpPort=8080


After taking few minutes, Jenkins will start running. Ensure that you make a not of the generated password that displays in the terminal Window or command prompt because you will require at the sime of setup.

Explore to http://localhost:8080 in your web browser to begin the configuration procedure. The main thing you see should look similar like the accompanying.

Simply ahead and enter the generated password to move onto the following screen. The following screen should provoke you to choose how you need to install accessible plugins.

I prescribe selecting the recommended modules to make your life less complicated.

It might require few minutes to install all the plugins relying upon your internet speed. When the plugins have installed, you'll be incited to make an administrator user.

Now you select to create an admin user account or skip and utilize the generated password for all the things.

Now Jenkins is configured and prepared to be utilized on your java hosting server. You'll see that no jobs have been made and we won't make any yet. To start with we need to install a missing module which will be utilized for the deployment of our containers.

Select Manage Jenkins and then Select Manage Plugins from the available list.

Look for Post-Build Script Plug-in from the rundown of accessible plugins. The reason we need this plugin is on the grounds that it will enable us to run shell commands and contents after the build step. In this example Jenkins exists on the host so it will have control over Docker. This implies we can deploy our container in the post-build step.

Once the module installed, we can move onto making our job. Keep in mind, the activity will download the code from Git, construct the project, construct a Docker image from the project, and convey the image.

Creating a Jenkins Job for Creating & Deploying an Application via Docker

The purpose of this illustration isn't concerning developing an application. Any random GitHub venture should work fine, yet for this example I will reference an Angular application we assembled a while back and uploaded.

From the root Jenkins window, select to create a new job.

We are going to make a Freestyle Project which will enable us to do anything. Give it a name and continue to the following screen where we can arrange our workspace source, manufacture process, and organization process.

Now on the window search the Source Code Management segment.

Here we are going to characterize the Git repository that we need to utilize. Like I stated,  we are utilizing a random project that we had once made. The catch here in this project is that our task has a Dockerfile document in it to characterize how the Docker image is made. On the off chance that you're interested, the repository we are utilizing is open and found at:

Subsequent to setting up the repository that will make up our workspace, we have to characterize the build procedure. Discover the Build segment of the screen.

A great deal of enchantment occurs in this segment of the procedure. At the point when the activity executes, it pulls from the Git repository. My specific repository has a catalog called gittalent-frontend which is what we will build. It is an Angular based project so we need to install every one of the conditions first. Angular needs the Node Package Manager (NPM), so in case you're doing likewise or comparative, you'll require Node.js accessible on an indistinguishable host from Jenkins.

After the project is designed by means of NPM, we can utilize the development dependencies that NPM acquired to manufacture the task with the Angular CLI. Presently recollect, the gittalent-frontend registry has a Dockerfile file in it. While not vital for this case, it takes the assembled Angular project and duplicates it into the image when we construct it.

cd gittalent-frontend

npm install

ng build

docker build -t frontend .


GIven above are the shell commands I am utilizing in my Build section, the last being the creation of an image known as frontend. Docker is functioning on the similar host as Jenkins on cloud server, so the image is going to be accessible.

The last an aspect of our responsibilities will be to deploy what we have built. Keep in mind that we installed a module that gives us a chance to utilize shell commands and contents. There are different modules that you can download for SSH and different things, yet it isn't excessively applicable for us.