GitHub - sid-shnkar/TodaySphere-NodeJS-App-Devops: TodaySphere Node.js App with completely automated deployment using Jenkins, AWS EC2, Docker and GitHub CI/CD

Configuration details:

  1. EC2 instance name: todaysphere-app
  2. Docker node.js app image name : todaysphere_app
  3. Docker node.js app container name: todaysphereapp
  4. App URL format - http://EC2_INSTANCE_PUBLIC_IP_ADDRESS:3000

Deployment link - https://todaysphere-app.onrender.com

Table of Contents

About The Project

Description

TodaySphere Node.js App which has completely automated deployment using Jenkins, AWS EC2, Docker and GitHub CI/CD. This app accepts location as an input from the user and based on that it shows the current weather, news for that location/region, an activity of the day which the user can perform and NASA's Astronomy Picture of the Day. A one-stop solution to start a good day! 😃

For the Devops part of this project, I created an AWS EC2 instance, installed Jenkins on the server, then integrated Jenkins with this GitHub repository containing Node.js app code. Next, using Docker, I dockerized the Node.js app and automated this process on Jenkins. Finally automated the whole process using GitHub Webhooks.

App Name: Today + Atmosphere(around you) - TodaySphere 😉

Technologies used

  1. Node.js
  2. AWS EC2
  3. Jenkins
  4. Docker
  5. GitHub Webhooks (for CI/CD)

APIs used

  1. WeatherStack
  2. Mapbox
  3. NewsAPI.org
  4. NASA Open APIs
  5. Bored API

Screenshots

screenshot-1 screenshot-2 screenshot-3 screenshot-4 screenshot-5 screenshot-6 screenshot-7 screenshot-8 screenshot-9 screenshot-10

Getting Started

To get started with the project, follow these steps:

Prerequisites

  • AWS account
  • GitHub account

Commands used

Note:

  • Make sure to enable port 8080 inbound traffic while creating the EC2 instance

  • (with default settings) Login as "ubuntu" using putty with the .ppk file

  • Inside the EC2 instance (choose OS as Ubuntu)

  • Installing Java inside EC2 instance
sudo apt install openjdk-11-jre
  • Installing Jenkins on EC2 instance
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key |sudo gpg --dearmor -o /usr/share/keyrings/jenkins.gpg
sudo sh -c 'echo deb [signed-by=/usr/share/keyrings/jenkins.gpg] http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
  /usr/share/keyrings/jenkins-keyring.asc > /dev/null
  
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
  https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
  /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo systemctl start jenkins.service
sudo systemctl status jenkins
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
  • After setting up Jenkins, use the following commands to integrate it with GitHub
  • Running the Node.js app on EC2 instance
cd /var/lib/jenkins/workspace/todaysphere-app
  • Installing Docker and Containerizing the Node.js app
sudo apt install docker.io
sudo chmod 777 /var/run/docker.sock
sudo docker build . -t todaysphere_app
sudo docker run -d --name todaysphereapp -p 3000:3000 todaysphere_app:latest
  • Jenkins Build step (execute shell)
docker build . -t todaysphere_app
docker container rm -f todaysphereapp
docker run -d --name todaysphereapp -p 3000:3000 todaysphere_app:latest
  • Optional - To open access to ports/firewall modification (incase 8080 port does not open)