-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
51 lines (44 loc) · 1.32 KB
/
deploy.sh
File metadata and controls
51 lines (44 loc) · 1.32 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
#실행중인 8080컨테이너 탐색
EXIST_GITCHAN=$(sudo docker compose -p docshelper-blue -f compose-blue.yml ps | grep Up)
#실행중인 8080컨테이너 없으면
if [ -z "$EXIST_GITCHAN" ]; then
echo "8080 컨테이너 실행"
sudo docker compose -p docshelper-blue -f compose-blue.yml up -d --force-recreate
BEFORE_COLOR="green"
AFTER_COLOR="blue"
BEFORE_PORT=8081
AFTER_PORT=8080
else
echo "8081 컨테이너 실행"
sudo docker compose -p docshelper-green -f compose-green.yml up -d --force-recreate
BEFORE_COLOR="blue"
AFTER_COLOR="green"
BEFORE_PORT=8080
AFTER_PORT=8081
fi
echo "${AFTER_COLOR} server up(port:${AFTER_PORT})"
# 2
for cnt in `seq 1 10`;
do
echo "Wait for server ...(${cnt}/10)";
UP=$(curl -s http://127.0.0.1:${AFTER_PORT}/api/health-check)
if [ "${UP}" != "OK" ]; then
sleep 10
continue
else
break
fi
done
if [ $cnt -eq 10 ]; then
echo "Server Error!!"
exit 1
fi
# 3
sudo sed -i "s/${BEFORE_PORT}/${AFTER_PORT}/" /etc/nginx/conf.d/service-url.inc
sudo nginx -s reload
echo "Deploy Completed!!"
# 4
echo "$BEFORE_COLOR server down(port:${BEFORE_PORT})"
sudo docker compose -p docshelper-${BEFORE_COLOR} -f compose-${BEFORE_COLOR}.yml down
# 5
sudo docker image prune -f