Build a Nodejs application through Jenkins pipeline and host it through Docker-compose.
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:
Click in Manage Plugins:
In Plugin manager, click on Available tab and after load the tab, search the plugins.
Search for nodejs and mark the checkbox
Click on button “Download now and install after restart”.
On next screen, mark the checkbox “Restart Jenkins when installation is complete and no jobs are running”.
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.
Search for NodeJS and click on NodeJS instalation button.
Put a name for node configuration, ex: node. Select the version of node that you need.
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>