Skip to content

Commit

Permalink
Merge pull request #132 from Team-Motivoo/docs/#131-deploy_scripts
Browse files Browse the repository at this point in the history
[DOCS] docker-compose.yml 파일 분리
  • Loading branch information
jun02160 authored Mar 3, 2024
2 parents 444170f + fd53612 commit 3294423
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/api-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
host: ${{ secrets.RELEASE_SERVER_IP }}
username: ${{ secrets.RELEASE_SERVER_USER }}
key: ${{ secrets.RELEASE_SERVER_KEY }}
source: "./docker-compose.yml"
source: "./docker-compose-api.yml"
target: "/home/ubuntu/"

deploy-cd: # job#2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/batch-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
host: ${{ secrets.RELEASE_SERVER_IP }}
username: ${{ secrets.RELEASE_SERVER_USER }}
key: ${{ secrets.RELEASE_SERVER_KEY }}
source: "./docker-compose.yml"
source: "./docker-compose-batch.yml"
target: "/home/ubuntu/"

deploy-cd: # job#2
Expand Down
25 changes: 0 additions & 25 deletions docker-compose.yml → docker-compose-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,6 @@ services:
# networks:
# - motivoo-net

blue-batch:
container_name: blue-batch
image: yejunpark1/motivoo-batch-server
expose:
- 8081
ports:
- "8081:8081"
environment:
- TZ=Asia/Seoul
# networks:
# - motivoo-net


green-api:
container_name: green-api
image: yejunpark1/motivoo-api-server
Expand All @@ -47,18 +34,6 @@ services:
depends_on:
- redis
# networks:
# - motivoo-net

green-batch:
container_name: green-batch
image: yejunpark1/motivoo-batch-server
expose:
- 8081
ports:
- "8083:8081"
environment:
- TZ=Asia/Seoul
# networks:
# - motivoo-net

#networks:
Expand Down
30 changes: 30 additions & 0 deletions docker-compose-batch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: '3.8'
services:

blue-batch:
container_name: blue-batch
image: yejunpark1/motivoo-batch-server
expose:
- 8081
ports:
- "8081:8081"
environment:
- TZ=Asia/Seoul
# networks:
# - motivoo-net

green-batch:
container_name: green-batch
image: yejunpark1/motivoo-batch-server
expose:
- 8081
ports:
- "8083:8081"
environment:
- TZ=Asia/Seoul
# networks:
# - motivoo-net

#networks:
# motivoo-net:
# driver: bridge
20 changes: 10 additions & 10 deletions scripts/api/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ WEB_HEALTH_CHECK_URL=/actuator/health
if [ -z "$IS_REDIS_ACTIVATE" ];then
echo "###### REDIS ######"
echo "[$NOW_TIME] Redis 도커 이미지 pull"
docker-compose pull redis
docker-compose -f docker-compose-api.yml pull redis
echo "[$NOW_TIME] Redis 컨테이너 Up (빌드 & 실행)"
docker-compose up -d redis
docker-compose -f docker-compose-api.yml up -d redis
fi

# 실행 중인 서버 포트 확인
Expand Down Expand Up @@ -54,9 +54,9 @@ if [ -z $IS_GREEN_ACTIVATE ]; then
CURRENT_SERVER_PORT=8082

echo "[$NOW_TIME] Green 도커 이미지 pull"
docker-compose pull green-api
docker-compose -f docker-compose-api.yml pull green-api
echo "[$NOW_TIME] Green 컨테이너 Up (빌드 & 실행)"
docker-compose up -d green-api
docker-compose -f docker-compose-api.yml up -d green-api
echo "[$NOW_TIME] 15초 후 Health Check 시작"
sleep 15

Expand All @@ -78,7 +78,7 @@ if [ -z $IS_GREEN_ACTIVATE ]; then
if [ $retry_count -eq 15 ]; then
echo "[$NOW_TIME] Health check 실패.."
echo "[$NOW_TIME] Nginx에 연결하지 않고 배포를 종료합니다."
docker-compose stop green-api
docker-compose -f docker-compose-api.yml stop green-api
exit 1
fi
done;
Expand All @@ -91,7 +91,7 @@ if [ -z $IS_GREEN_ACTIVATE ]; then
sudo nginx -s reload
echo "[$NOW_TIME] 스위칭 후 실행 중인 Port: $(sudo cat /etc/nginx/conf.d/service-url.inc)"
echo "[$NOW_TIME] Blue 컨테이너 중단"
docker-compose stop blue-api
docker-compose -f docker-compose-api.yml stop blue-api

# Blue Up
else
Expand All @@ -101,9 +101,9 @@ else
CURRENT_SERVER_PORT=8080

echo "[$NOW_TIME] Blue 도커 이미지 pull"
docker-compose pull blue-api
docker-compose -f docker-compose-api.yml pull blue-api
echo "[$NOW_TIME] Blue 컨테이너 Up (빌드 & 실행)"
docker-compose up -d blue-api
docker-compose -f docker-compose-api.yml up -d blue-api
echo "[$NOW_TIME] 15초 후 Health Check 시작"
sleep 15

Expand All @@ -126,7 +126,7 @@ else
if [ $retry_count -eq 15 ]; then
echo "[$NOW_TIME] Health check 실패.."
echo "[$NOW_TIME] Nginx에 연결하지 않고 배포를 종료합니다."
docker-compose stop blue-api
docker-compose -f docker-compose-api.yml stop blue-api
exit 1
fi
done;
Expand All @@ -139,7 +139,7 @@ else
sudo nginx -s reload
echo "[$NOW_TIME] 스위칭 후 실행 중인 Port: $(sudo cat /etc/nginx/conf.d/service-url.inc)"
echo "[$NOW_TIME] Green 컨테이너 중단"
docker-compose stop green-api
docker-compose -f docker-compose-api.yml stop green-api
fi

echo "----------------------------------------------------------------------"
Expand Down
15 changes: 7 additions & 8 deletions scripts/batch/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ if [ -z $IS_GREEN_ACTIVATE ]; then
CURRENT_SERVER_PORT=8083

echo "[$NOW_TIME] Green 도커 이미지 pull"
docker-compose pull green-batch
docker-compose -f docker-compose-batch.yml pull green-batch
echo "[$NOW_TIME] Green 컨테이너 Up (빌드 & 실행)"
docker-compose up -d green-batch
docker-compose -f docker-compose-batch.yml up -d green-batch
echo "[$NOW_TIME] 10초 후 Health Check 시작"
sleep 10

Expand Down Expand Up @@ -81,7 +81,7 @@ if [ -z $IS_GREEN_ACTIVATE ]; then
sudo nginx -s reload
echo "[$NOW_TIME] 스위칭 후 실행 중인 Port: $(sudo cat /etc/nginx/conf.d/service-url-batch.inc)"
echo "[$NOW_TIME] Blue 컨테이너 중단"
docker-compose stop blue-batch
docker-compose -f docker-compose-batch.yml stop blue-batch

# Blue Up
else
Expand All @@ -91,9 +91,9 @@ else
CURRENT_SERVER_PORT=8081

echo "[$NOW_TIME] Blue 도커 이미지 pull"
docker-compose pull blue-batch
docker-compose -f docker-compose-batch.yml pull blue-batch
echo "[$NOW_TIME] Blue 컨테이너 Up (빌드 & 실행)"
docker-compose up -d blue-batch
docker-compose -f docker-compose-batch.yml up -d blue-batch
echo "[$NOW_TIME] 10초 후 Health Check 시작"
sleep 10

Expand Down Expand Up @@ -128,7 +128,7 @@ else
sudo nginx -s reload
echo "[$NOW_TIME] 스위칭 후 실행 중인 Port: $(sudo cat /etc/nginx/conf.d/service-url-batch.inc)"
echo "[$NOW_TIME] Green 컨테이너 중단"
docker-compose stop green-batch
docker-compose -f docker-compose-batch.yml stop green-batch
fi

echo "----------------------------------------------------------------------"
Expand All @@ -145,5 +145,4 @@ else
echo "[$NOW_TIME] 서버 변경 실패"
echo "[$NOW_TIME] 서버 응답 결과: ${RESPONSE}"
exit 1
fi

fi

0 comments on commit 3294423

Please sign in to comment.