Skip to content

Commit

Permalink
chore: prod > blue,green 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
clean2001 committed Oct 29, 2024
1 parent fd4d149 commit c2c1877
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions layer-api/infra/production/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

IS_GREEN=$(docker ps | grep green) # 현재 실행중인 App이 blue인지 확인합니다.
IS_GREEN=$(sudo docker ps | grep green) # 현재 실행중인 App이 blue인지 확인합니다.
DEFAULT_CONF=" /etc/nginx/nginx.conf"

if [ -z $IS_GREEN ];then # blue라면
Expand All @@ -9,16 +9,16 @@ if [ -z $IS_GREEN ];then # blue라면

echo "1. get green image"
cd ./layer-api/infra/production
docker-compose pull clean01/layer-server_layer-api:latest # green으로 이미지를 내려받습니다.
sudo docker-compose pull clean01/layer-server_layer-api:latest # green으로 이미지를 내려받습니다.

echo "2. green container up"
docker-compose up -d green # green 컨테이너 실행
sudo docker-compose up -d green # green 컨테이너 실행

while [ 1 = 1 ]; do
echo "3. green health check..."
sleep 3
sudo sleep 3

REQUEST=$(curl http://127.0.0.1:8080) # green으로 request
REQUEST=$(sudo curl http://127.0.0.1:8080) # green으로 request
if [ -n "$REQUEST" ]; then # 서비스 가능하면 health check 중지
echo "health check success"
break ;
Expand All @@ -30,14 +30,14 @@ if [ -z $IS_GREEN ];then # blue라면
sudo nginx -s rel

echo "5. blue container down"
docker-compose stop blue
sudo docker-compose stop blue
else
echo "1. get green image"
cd ./layer-api/infra/production
docker-compose pull clean01/layer-server_layer-api:latest # green으로 이미지를 내려받습니다.
sudo docker-compose pull clean01/layer-server_layer-api:latest # green으로 이미지를 내려받습니다.

echo "2. blue container up"
docker-compose up -d blue # green 컨테이너 실행
sudo docker-compose up -d blue # green 컨테이너 실행


while [ 1 = 1 ]; do
Expand All @@ -56,5 +56,5 @@ else
sudo nginx -s reload

echo "5. green container down"
docker-compose stop green
sudo docker-compose stop green
fi

0 comments on commit c2c1877

Please sign in to comment.