Skip to content

Commit

Permalink
Merge pull request #202 from 2023-Team-Luna-Achieve/BE/Feat/#198
Browse files Browse the repository at this point in the history
fix: cicd
  • Loading branch information
yoojaeyoonGit authored May 23, 2024
2 parents c38c2c1 + 9687e17 commit a15ecdc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ echo "배포 시작일자 : $(TZ="Asia/Seoul" date '+%Y-%m-%d %H:%M:%S')" >> /op
if [ -z "$EXIST_BLUE" ]; then
echo "blue 배포 시작 : $(TZ="Asia/Seoul" date '+%Y-%m-%d %H:%M:%S')" >> /opt/deploy.log

echo sudo docker-compose -p ${DOCKER_APP_NAME}-blue -f docker-compose-blue.yml up -d --build >> /opt/docker-deploy.log
sudo docker-compose -p ${DOCKER_APP_NAME}-blue -f docker-compose-blue.yml up -d --build

sleep 120

Expand All @@ -53,8 +53,9 @@ if [ -z "$EXIST_BLUE" ]; then
FRONTEND_CONTAINER_STATUS=docker inspect frontend-blue | grep '"Status":' | head -n 1 | awk -F: '{print $2}' | tr -d ' ",'
REDIS_CONTAINER_STATUS=docker inspect redis-blue | grep '"Status":' | head -n 1 | awk -F: '{print $2}' | tr -d ' ",'

if [ -z "$BLUE_STATUS" ] || [ "$BACKEND_CONTAINER_STATUS" == "exited" ] || [ "$FRONTEND_CONTAINER_STATUS" == "exited" ] || [ "$REDIS_CONTAINER_STATUS" == "exited" ]; then
if [ -z "$BLUE_STATUS" ] || [ "$BACKEND_CONTAINER_STATUS" = "exited" ] || [ "$FRONTEND_CONTAINER_STATUS" = "exited" ] || [ "$REDIS_CONTAINER_STATUS" = "exited" ]; then
"에러 발생" >> /opt/deploy.log
sudo docker-compose -p ${DOCKER_APP_NAME}-blue -f docker-compose-green.yml down -v --rmi all
echoIfContainerExcited BACKEND_CONTAINER_STATUS FRONTEND_CONTAINER_STATUS REDIS_CONTAINER_STATUS

cat /opt/deploy-report-email/deploy-fail-email.txt | ssmtp -v -t
Expand All @@ -73,7 +74,7 @@ if [ -z "$EXIST_BLUE" ]; then

else
echo "green 배포 시작 : $(TZ="Asia/Seoul" date '+%Y-%m-%d %H:%M:%S')" >> /opt/deploy.log
echo sudo docker-compose -p ${DOCKER_APP_NAME}-green -f docker-compose-green.yml up -d --build >> /opt/docker-deploy.log
echo sudo docker-compose -p ${DOCKER_APP_NAME}-blue -f docker-compose-blue.yml up -d --build >> /opt/docker-deploy.log
sleep 120


Expand All @@ -82,8 +83,9 @@ else
FRONTEND_CONTAINER_STATUS=docker inspect frontend-green | grep '"Status":' | head -n 1 | awk -F: '{print $2}' | tr -d ' ",'
REDIS_CONTAINER_STATUS=docker inspect redis-green | grep '"Status":' | head -n 1 | awk -F: '{print $2}' | tr -d ' ",'

if [ -z "$GREEN_STATUS" ] || [ "$BACKEND_CONTAINER_STATUS" == "exited" ] || [ "$FRONTEND_CONTAINER_STATUS" == "exited" ] || [ "$REDIS_CONTAINER_STATUS" == "exited" ]; then
if [ -z "$GREEN_STATUS" ] || [ "$BACKEND_CONTAINER_STATUS" = "exited" ] || [ "$FRONTEND_CONTAINER_STATUS" = "exited" ] || [ "$REDIS_CONTAINER_STATUS" = "exited" ]; then
"에러 발생" >> /opt/deploy.log
sudo docker-compose -p ${DOCKER_APP_NAME}-green -f docker-compose-green.yml down -v --rmi all
echoIfContainerExcited BACKEND_CONTAINER_STATUS FRONTEND_CONTAINER_STATUS REDIS_CONTAINER_STATUS

cat /opt/deploy-report-email/deploy-fail-email.txt | ssmtp -v -t
Expand Down

0 comments on commit a15ecdc

Please sign in to comment.