Objective | - Deploy end-to-end application in node.js using Jenkins CICD with GitHub Integration - Trigger Jenkins pipeline automatically once the code is pushed on GitHub |
Approach | - Using Amazon's Elastic Compute Cloud (EC2) for running application on the Amazon Web Services (AWS) infrastructure - Containerize application by creating Dockerfile - Integrate GitHub with Jenkins using Webhook |
Impact | - Jenkins pipeline triggers automatically once the code is pushed on GitHub - Accomplish faster quality releases by automating CI/CD pipelines |
Primary Technology: Github, Docker, Jenkins, aws EC2 service
Before we write any CI/CD pipeline we need an application to test and deploy. We are going to build a simple to-do application in node.js. Then, create new repository under your GitHub account and name it “node-todo-cicd”.
After logging into your AWS account, search for EC2
Select t2.micro as Instance type and create new key pair to connect to the server
Enter key pair name and select RSA as Key pair type and .pem as Private key file format. Then, click Create key pair R
Install node version manager (nvm) by typing the following at the command line.
sudo su -
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
Activate nvm by typing the following at the command line.
. ~/.nvm/nvm.sh
Use nvm to install the latest version of Node.js by typing the following at the command line.
nvm install node
Test that node and npm are installed and running correctly by typing the following at the terminal:
node -v
npm -v
To install git, run below commands in the terminal window:
sudo apt-get update -y
sudo apt-get install git -y
Just to verify if system has git installed or not, please run below command in terminal:
git — version
This command will print the git version in the terminal.
Run below command to clone the code repository from Github:
Git Clone : https://github.com/Aseemakram19/nodejs-on-ec2-youtube.git
Branch Master.
Get inside the directory and Install Packages
cd nodejs-on-ec2
npm install
Start the application To start the application, run the below command in the terminal:
npm start