Build a Nodejs application through Jenkins pipeline and host it through Docker-compose.

Armaan Zaheer
3 min readNov 12, 2021

Requirements-

1- Docker

2- Docker-compose

3- Jenkins

4- Nodejs

5- npm

📌Here is my GitHub Repo Link:-

step1- install Docker in your system

Step2- install Docker-compose

Step3- Install Jenkins

Step4- Install nodejs, npm

In this article, we are talking about how to Build Node.js on Jenkins with Docker-compose

Here we go -

Firstly we create Dockerfile.

Setup Jenkins-

After setting up Jenkins we need to configure NodeJS on Jenkins.

Installing Node.js tool

In home of jenkins, click in Manage Jenkins:

Jenkins menu

Click in Manage Plugins:

Manage Plugins

In Plugin manager, click on Available tab and after load the tab, search the plugins.

Installation tabs

Search for nodejs and mark the checkbox

NodeJS plugin checked

Click on button “Download now and install after restart”.

Download now and install after restart button

On next screen, mark the checkbox “Restart Jenkins when installation is complete and no jobs are running”.

Installating Plugins with Restart checked

Wait a moment, if the screen not change, go to jenkins home clicking in jenkins’s logo on top, in the left side of the site.

Configuring Node.js tool

After installed and restarted, go to jenkins’s home > Manage Jenkins > Global Tool Configuration.

Global Tool Configuration

Search for NodeJS and click on NodeJS instalation button.

NodeJS Installations button

Put a name for node configuration, ex: node. Select the version of node that you need.

NodeJS config

Create a Node application job

Step1: Now, in the project directory, we’ll create app.js and it’s code is given below.

Work of docker-compose-

Jenkins pipline-

Now you can run your application <ip appderss>:<port>

Hurrayyy!! We have successfully deploy a nodejs application using jenkins pipeline that is hosted on docker-compose and dockerfile.. 😊✌

--

--