-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
61 lines (46 loc) · 1.75 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
pipeline {
agent any
stages {
stage('Test'){
steps{
/*
dir("service1") {
sh "python3 -m pytest --cov=app"
}*/
dir("service2") {
sh "python3 -m pytest --cov=app"
}
dir("service3") {
sh "python3 -m pytest --cov=app"
}
dir("service4") {
sh "python3 -m pytest --cov=app"
}
}
}
stage('Build'){
steps{
sh 'docker-compose build'
}
}
stage('Configure - Ansible'){
steps{
sh 'ansible-playbook -i inventory.yaml playbook.yaml'
}
}
stage('Deploy'){
steps{
sh 'scp docker-compose.yaml [email protected]:docker-compose.yaml && docker-compose push'
sh "ssh 35.188.151.251 docker stack deploy --compose-file docker-compose.yaml flaskapp"
}
}
stage('LoadBalancer'){
steps{
sh 'scp nginx/nginx.conf [email protected]:nginx'
sh "ssh [email protected] docker service rm nginx-loadbalancer"
sh "ssh [email protected] docker service create -d -p 80:80 --name nginx-loadbalancer --mount type=bind,source=/home/jenkins/nginx.conf,target=/etc/nginx/nginx.conf nginx:alpine"
sh "ssh [email protected] docker service update --replicas 4 nginx-loadbalancer"
}
}
}
}