AWS + Docker +Git+ Jenkins  hands-on

AWS + Docker +Git+ Jenkins hands-on

Hi Everyone, lets do a quick hands-on involving AWS+Docker+Git+Jenkins

Go to AWS console & launch a EC2 instance named Jenkins Server and use Ubuntu AMI.

Select desired key pair & launch the instance

2) Go jenkins website & install jenkins : https://www.jenkins.io/doc/book/installing/linux/

make sure firrst JAVA is installed on your EC2 instance if not install it using below commands:

sudo apt update sudo apt install fontconfig openjdk-17-jre java -version openjdk version "17.0.8" 2023-07-18 OpenJDK Runtime Environment (build 17.0.8+7-Debian-1deb12u1) OpenJDK 64-Bit Server VM (build 17.0.8+7-Debian-1deb12u1, mixed mode, sharing)

once Java is installed, install the jenkins It can be installed from the debian apt repository. [:

sudo wget -O /](https://pkg.jenkins.io/debian/)usr/share/keyrings/jenkins-keyring.aschttps://pkg.jenkins.io/debian/jenkins.io-2023.key echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]https://pkg.jenkins.io/debian binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null sudo apt-get update sudo apt-get install jenkins

Verify the jenkins status using systemctl ststus jenkins

Jenkins runs on port 8080

Get the EC2 instance IP access it on port 8080 & unlock the jenkins & create first user. after that jenkins will look like this

3) Install docker using below command

"/"sudo apt-get install docker.io

add jenkins user to communicate with docker using below commands:

"/"sudo usermod -aG docker jenkins

then reboot the instance to make changes effective "/" sudo reboot

4) Create a freestyle project job in jenkins

use Github project : https://github.com/Shubham051997/react_django_demo_app.git

Add Github's repository url under source code management

url : https://github.com/Shubham051997/react_django_demo_app.git

make sure Branch is set to */main

In build steps add following commands :

echo "code cloned"

docker build . -t django-app

echo "code built" docker run -d -p 8001:8001 django-app:latest

echo "code Deployed"

save & run the file:

Check the console output for any errors:

App should be working on port 8001 (use EC2 instance ip)

App works fine :)

Hope you would have liked this blog.
drop your suggestions if any.
thanks for reading.

Did you find this article valuable?

Support SHUBHAM BHAT's blog by becoming a sponsor. Any amount is appreciated!