forked from team-abcdedu/abcdedu-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
36 lines (35 loc) · 960 Bytes
/
deploy.sh
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
#!/bin/bash
IS_BLUE=$(docker ps | grep blue | wc -l)
if [ ${IS_BLUE} -eq 1 ]; then
docker-compose up -d green
while [ 1 = 1 ]; do
sleep 3
REQUEST=$(curl http://localhost:8082/api/v1/actuator/health)
IS_ACTIVE=$(echo ${REQUEST} | grep 'UP' | wc -l)
if [ ${IS_ACTIVE} -eq 1 ] ; then
break;
fi
done;
sleep 3
sudo cp /etc/nginx/sites-available/green /etc/nginx/sites-enabled/default
sudo nginx -s reload
docker-compose stop blue
docker-compose rm blue
docker image prune -a -f
else
docker-compose up -d blue
while [ 1 = 1 ]; do
sleep 3
REQUEST=$(curl http://localhost:8081/api/v1/actuator/health)
IS_ACTIVE=$(echo ${REQUEST} | grep 'UP' | wc -l)
if [ ${IS_ACTIVE} -eq 1 ] ; then
break;
fi
done;
sleep 3
sudo cp /etc/nginx/sites-available/blue /etc/nginx/sites-enabled/default
sudo nginx -s reload
docker-compose stop green
docker-compose rm green
docker image prune -a -f
fi