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