Skip to content

Commit 6801b4c

Browse files
authored
Create GITDevOPS
1 parent 74be1ea commit 6801b4c

1 file changed

Lines changed: 145 additions & 0 deletions

File tree

GIT/GITDevOPS

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
Create a Server for Devloper1
2+
Install git on it
3+
4+
Go to Git hub and create a repository with readme file added
5+
6+
there will be a defualt main branch
7+
8+
Create 3 more branches Dev, QA, Prod
9+
10+
Make Dev branch as defualt branch
11+
12+
Go to Settings--> Branches--> click on switch to other branches--> select dev in drop down and click on update
13+
14+
Now dev is default branch
15+
16+
And delete main branch
17+
18+
go to local machine of Developer and Clone the git hub repository
19+
20+
Dev branch must be there.
21+
22+
Create a new file with index1.html and save it
23+
24+
<h1> this my app </h1>
25+
<h1> created by Sonal</h1>
26+
27+
Add file to local repo and push the code to Remote repo under dev branch
28+
29+
# git add .
30+
# git commit -m "added index1.html"
31+
# git push origin Dev
32+
33+
Check in github under Dev do we have the file
34+
35+
Now Build and Deploy the code using Jenkins & Docker
36+
37+
Go to jenkins--> DeployDev Job
38+
give the new repo name and branch name as Dev
39+
40+
under build give this script
41+
42+
rm -rf mydockerfile
43+
mkdir mydockerfile
44+
cd mydockerfile
45+
cp /var/lib/jenkins/workspace/DeployDev/index1.html .
46+
touch dockerfile
47+
cat <<EOT>> dockerfile
48+
FROM ubuntu
49+
RUN apt-get update
50+
RUN apt-get install nginx -y
51+
COPY index1.html /var/www/html
52+
EXPOSE 80
53+
CMD ["nginx","-g","daemon off;"]
54+
EOT
55+
sudo docker build -t myimage:$BUILD_NUMBER .
56+
sudo docker run -itd -P myimage:$BUILD_NUMBER
57+
58+
59+
Code will be deployed at URL : http://3.143.147.140:32776/index1.html
60+
61+
62+
********************************************
63+
64+
Now go to Git hub and create pull request to merge code with QA branch
65+
66+
Now Build and Deploy the code using Jenkins & Docker
67+
68+
Go to jenkins--> DeployQA Job
69+
give the new repo name and branch name as QA
70+
71+
under build give this script
72+
73+
rm -rf mydockerfile
74+
mkdir mydockerfile
75+
cd mydockerfile
76+
cp /var/lib/jenkins/workspace/DeployQA/index1.html .
77+
touch dockerfile
78+
cat <<EOT>> dockerfile
79+
FROM ubuntu
80+
RUN apt-get update
81+
RUN apt-get install nginx -y
82+
COPY index1.html /var/www/html
83+
EXPOSE 80
84+
CMD ["nginx","-g","daemon off;"]
85+
EOT
86+
sudo docker build -t myimage:$BUILD_NUMBER .
87+
sudo docker run -itd -P myimage:$BUILD_NUMBER
88+
89+
90+
Code will be deployed at URL : http://3.143.147.140:32776/index1.html
91+
92+
93+
As there will be defects , go to local repo and make chnages to index1.html for defect fix as part of QA
94+
95+
Push the code to Dev branch first
96+
97+
Build and Deploy in DEV Server
98+
99+
Now merge DEV code to QA branch in deploy in QA
100+
101+
*************************************
102+
103+
Once everything is tested in QA,
104+
105+
Create a pull request to merge QA branch to Prod branch
106+
107+
108+
Now Build and Deploy the code using Jenkins & Docker
109+
110+
Go to jenkins--> DeployProd Job
111+
give the new repo name and branch name as Prod
112+
113+
under build give this script
114+
115+
rm -rf mydockerfile
116+
mkdir mydockerfile
117+
cd mydockerfile
118+
cp /var/lib/jenkins/workspace/DeployProd/index1.html .
119+
touch dockerfile
120+
cat <<EOT>> dockerfile
121+
FROM ubuntu
122+
RUN apt-get update
123+
RUN apt-get install nginx -y
124+
COPY index1.html /var/www/html
125+
EXPOSE 80
126+
CMD ["nginx","-g","daemon off;"]
127+
EOT
128+
sudo docker build -t myimage:$BUILD_NUMBER .
129+
sudo docker run -itd -P myimage:$BUILD_NUMBER
130+
131+
132+
Code will be deployed at URL : http://3.143.147.140:32776/index1.html
133+
134+
135+
136+
137+
138+
139+
140+
141+
142+
143+
144+
145+

0 commit comments

Comments
 (0)