-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
188 lines (188 loc) · 6.65 KB
/
Jenkinsfile
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
pipeline {
agent any
stages {
stage('Fetch Repos') {
steps {
withCredentials([gitUsernamePassword(credentialsId: 'mahmed-amer-key-1', gitToolName: 'git-tool')]) {
sh '''
git checkout master
git submodule update --init --recursive
git submodule update --recursive --remote --merge
cd Backend
git fetch
git checkout solve-testing
git merge origin/solve-testing
cd ../Frontend
git fetch
git checkout fix_fetal_bugs
git merge origin/fix_fetal_bugs
echo "All repos are here"
'''
}
}
}
stage('Build DEV Backend Development Image'){
steps{
sh '''
cp backend.Dockerfile ./Backend/Dockerfile
cd Backend
docker build -t backend:dev .
'''
}
}
stage('Build DEV Frontend Development Image') {
environment {
REACT_APP_GOOGLE_ID = credentials('REACT_APP_GOOGLE_ID')
REACT_APP_GOOGLE_SECRET = credentials('REACT_APP_GOOGLE_SECRET')
REACT_APP_GITHUB_ID = credentials('REACT_APP_GITHUB_ID')
REACT_APP_GITHUB_SECRET = credentials('REACT_APP_GITHUB_SECRET')
}
steps{
sh '''
export REACT_APP_BASE_URL="http://back-dev:3000"
cp frontend.Dockerfile ./Frontend/reddit-front/Dockerfile
cp frontend.nginx.conf ./Frontend/reddit-front/nginx.conf
cd Frontend/reddit-front
rm .env -f
echo REACT_APP_BASE_URL=$REACT_APP_BASE_URL > .env
echo REACT_APP_GOOGLE_ID=$REACT_APP_GOOGLE_ID >> .env
echo REACT_APP_GOOGLE_SECRET=$REACT_APP_GOOGLE_SECRET >> .env
echo REACT_APP_GITHUB_ID=$REACT_APP_GITHUB_ID >> .env
echo REACT_APP_GITHUB_SECRET=$REACT_APP_GITHUB_SECRET >> .env
docker build -t frontend:dev .
'''
}
}
stage('Build DEV Cross-Platform Development Image'){
steps{
sh '''
cp cross.Dockerfile ./Cross-Platform/reddit/Dockerfile
cp cross.nginx.conf ./Cross-Platform/reddit/nginx.conf
cd Cross-Platform/reddit
export BASE_URL=https://demosfortest.com/api/
export MEDIA_URL=https://static.demosfortest.com/
docker build -t cross:prod --build-arg BSE_URL=$BASE_URL --build-arg MDIA_URL=$MEDIA_URL .
'''
}
}
stage('Build DEV Testing Image') {
steps{
sh '''
cp testing.Dockerfile ./Testing/Dockerfile
cd Testing
rm .env -f
echo BASE_URL=http://front-dev > .env
docker build -t testing:dev .
'''
}
}
stage('Run Dev Containers For Testing') {
environment {
MONGO_INITDB_ROOT_USERNAME = credentials('MONGO_INITDB_ROOT_USERNAME')
MONGO_INITDB_ROOT_PASSWORD = credentials('MONGO_INITDB_ROOT_PASSWORD')
JWT_SECRET = credentials('JWT_SECRET')
FORGET_PASSWORD_SECRET = credentials('FORGET_PASSWORD_SECRET')
SU_USERNAME = credentials('SU_USERNAME')
SU_EMAIL = credentials('SU_EMAIL')
SU_PASS = credentials('SU_PASS')
EMAIL_USER = credentials('EMAIL_USER')
EMAIL_PASS = credentials('EMAIL_PASS')
GOOGLE_CREDIENTIALS_CLIENT_ID_web = credentials('GOOGLE_CREDIENTIALS_CLIENT_ID_web')
GOOGLE_CREDIENTIALS_CLIENT_ID_flutter_web = credentials('GOOGLE_CREDIENTIALS_CLIENT_ID_flutter_web')
GOOGLE_CREDIENTIALS_CLIENT_ID_flutter_android = credentials('GOOGLE_CREDIENTIALS_CLIENT_ID_flutter_android')
}
steps {
sh '''
export BASE_URL="http://back-dev:3000"
export REACT_APP_BASE_URL="http://back-dev:3000"
export DB_CONNECTION_STRING=mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@mongo-db-dev:27017
docker-compose -f 'docker-compose-dev.yml' -p 'swproject-dev' up -d
'''
}
}
stage('Run Tests') {
steps{
sh '''
docker run --network=swproject-dev_default --cpus=2 --memory=4096m -w /e2e testing:dev
'''
}
}
stage('Remove Dev Containers For Testing') {
steps{
sh '''
docker-compose -f 'docker-compose-dev.yml' -p 'swproject-dev' stop
docker-compose -f 'docker-compose-dev.yml' -p 'swproject-dev' down
'''
}
}
stage('Build PROD Backend Development Image'){
steps{
sh '''
cp backend.Dockerfile ./Backend/Dockerfile
cd Backend
docker build -t backend:prod .
'''
}
}
stage('Build PROD Frontend Development Image') {
environment {
REACT_APP_BASE_URL = credentials('BASE_URL')
REACT_APP_GOOGLE_ID = credentials('REACT_APP_GOOGLE_ID')
REACT_APP_GOOGLE_SECRET = credentials('REACT_APP_GOOGLE_SECRET')
REACT_APP_GITHUB_ID = credentials('REACT_APP_GITHUB_ID')
REACT_APP_GITHUB_SECRET = credentials('REACT_APP_GITHUB_SECRET')
}
steps{
sh '''
cp frontend.Dockerfile ./Frontend/reddit-front/Dockerfile
cp frontend.nginx.conf ./Frontend/reddit-front/nginx.conf
cd Frontend/reddit-front
rm .env -f
echo REACT_APP_BASE_URL=$REACT_APP_BASE_URL > .env
echo REACT_APP_GOOGLE_ID=$REACT_APP_GOOGLE_ID >> .env
echo REACT_APP_GOOGLE_SECRET=$REACT_APP_GOOGLE_SECRET >> .env
echo REACT_APP_GITHUB_ID=$REACT_APP_GITHUB_ID >> .env
echo REACT_APP_GITHUB_SECRET=$REACT_APP_GITHUB_SECRET >> .env
docker build -t frontend:prod .
'''
}
}
stage('Build PROD Cross-Platform Development Image'){
steps{
sh '''
cp cross.Dockerfile ./Cross-Platform/reddit/Dockerfile
cp cross.nginx.conf ./Cross-Platform/reddit/nginx.conf
cd Cross-Platform/reddit
export BASE_URL=https://demosfortest.com/api/
export MEDIA_URL=https://static.demosfortest.com/
docker build -t cross:prod --build-arg BSE_URL=$BASE_URL --build-arg MDIA_URL=$MEDIA_URL .
'''
}
}
stage('Run New Prod Containers') {
environment {
MONGO_INITDB_ROOT_USERNAME = credentials('MONGO_INITDB_ROOT_USERNAME')
MONGO_INITDB_ROOT_PASSWORD = credentials('MONGO_INITDB_ROOT_PASSWORD')
JWT_SECRET = credentials('JWT_SECRET')
BASE_URL = credentials('BASE_URL')
REACT_APP_BASE_URL = credentials('BASE_URL')
FORGET_PASSWORD_SECRET = credentials('FORGET_PASSWORD_SECRET')
SU_USERNAME = credentials('SU_USERNAME')
SU_EMAIL = credentials('SU_EMAIL')
SU_PASS = credentials('SU_PASS')
EMAIL_USER = credentials('EMAIL_USER')
EMAIL_PASS = credentials('EMAIL_PASS')
GOOGLE_CREDIENTIALS_CLIENT_ID_web = credentials('GOOGLE_CREDIENTIALS_CLIENT_ID_web')
GOOGLE_CREDIENTIALS_CLIENT_ID_flutter_web = credentials('GOOGLE_CREDIENTIALS_CLIENT_ID_flutter_web')
GOOGLE_CREDIENTIALS_CLIENT_ID_flutter_android = credentials('GOOGLE_CREDIENTIALS_CLIENT_ID_flutter_android')
}
steps {
sh '''
export DB_CONNECTION_STRING=mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@mongo-db-prod:27017
docker build -t myproxy:prod -f proxy.Dockerfile .
docker-compose -f 'docker-compose-prod.yml' -p 'swproject-prod' up -d
'''
}
}
}
}