The Active link For this project is : - http://20.40.57.2:80
Github Repo Link :- https://github.com/kus123123/django-notes-app.git
The 2 contains one frontend and other sqlite .
Steps To Follow
Create a Virtual Machine in azure with ubuntu os .
i have connected vm using password and also via ssh . ssh is more secure . you just need to create pem file and ssh command
ssh project1@74.235.148.143
or
ssh -i /home/kus/Downloads/indian_server.pem azureuser@
20.40.57.2
now we will install jenkins on this machine
Before Jenkins We need to install java on machine
sudo apt update
sudo apt install openjdk-17-jre
java -version
curl -fsSL https://pkg.jenkins.io/debian/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 binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
Creating a pipeline project in Jenkinks
Prerequisite :
install docker on a machine via command and give Jenkins permission for docker
sudo apt install docker.io
sudo usermod -aG docker jenkins
sudo reboot
docker login
username :
password :
Steps To Follow in Jenkins:
1) First we need to create a Declarative Pipeline where
2 create pipleline Script
pipeline {
agent any
stages {
stage('clone') {
steps {
echo 'cloning'
git url: "https://github.com/kus123123/django-notes-app.git" ,branch: "main"
}
}
stage('build')
{
steps{
echo 'building'
sh "docker build -t notesapp1 ."
}
}
stage('running contianer'){
steps{
echo 'running container'
sh "docker run -d -p 8000:8000 notesapp1"
}
}
stage ('copying file to nginx'){
steps{
echo "copying files to nginx"
}
}
}
}
Then configure github Webooks:
These can be easily conigured used githun PAN token . which are generated in developer setting of github .
Also we need to add username and PAN in pipeline syntax in version control
Setting up Nginx
We can easily set up nginx -proxy using the
/etc/nginx/site-enabled/default
and adding
server_name _;
#For Front-End
location / {
proxy_pass http://127.0.0.1:8000;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
#For -backend
location /api {
proxy_pass http://127.0.0.1:8000/api;
}
Monitoring :-
Monitoring In Azure is setup using insights and alerts :
Optimization:
the optimization would include automating nginx also .
Using Kubernetes to run frontend and backend on different node
making Robust pipeline using Docker compose