diff --git a/.github/workflows/deploy-test.yml b/.github/workflows/deploy-test.yml index 7ed8debc..b1ee1015 100644 --- a/.github/workflows/deploy-test.yml +++ b/.github/workflows/deploy-test.yml @@ -75,13 +75,13 @@ jobs: run: | aws s3 cp \ --region ap-northeast-2 \ - ./yello-build.zip s3://yello-test-application-bucket + ./yello-build.zip s3://yello-test-bucket - name: 📡 CodeDeploy에 배포를 요청합니다. - run: aws deploy create-deployment --application-name yello-deploy-application + run: aws deploy create-deployment --application-name yello-test-deploy --deployment-config-name CodeDeployDefault.OneAtATime - --deployment-group-name yello-testing - --s3-location bucket=yello-test-application-bucket,bundleType=zip,key=yello-build.zip + --deployment-group-name yello-test-deploy + --s3-location bucket=yello-test-bucket,bundleType=zip,key=yello-build.zip - name: 💡 배포 상태를 Slack을 통해 전송합니다. uses: rtCamp/action-slack-notify@v2 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 61af885c..079853d7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -76,13 +76,13 @@ jobs: run: | aws s3 cp \ --region ap-northeast-2 \ - ./yello-build.zip s3://yello-server-bucket + ./yello-build.zip s3://yello-bucket - name: 📡 CodeDeploy에 배포를 요청합니다. - run: aws deploy create-deployment --application-name yello-server-deploy + run: aws deploy create-deployment --application-name yello-deploy --deployment-config-name CodeDeployDefault.OneAtATime - --deployment-group-name yello-app - --s3-location bucket=yello-server-bucket,bundleType=zip,key=yello-build.zip + --deployment-group-name yello-deploy + --s3-location bucket=yello-bucket,bundleType=zip,key=yello-build.zip - name: 💡 배포 상태를 Slack을 통해 전송합니다. uses: rtCamp/action-slack-notify@v2 diff --git a/.gitignore b/.gitignore index 8ac8c49c..e624bf03 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,8 @@ application-local.yml firebase*.json *client_secret*.json +docker/rabbitmq/** + ### monitoring ### monitoring/prometheus/volume monitoring/grafana diff --git a/appspec.yml b/appspec.yml index a5cc70a2..ee61501d 100644 --- a/appspec.yml +++ b/appspec.yml @@ -5,15 +5,15 @@ os: linux ## 코드 파일 전송 files: - source: / - destination: /home/ec2-user/app + destination: /home/ubuntu/app overwrite: yes # overwrite 허용 여부 ## 권한 설정 permissions: - object: / pattern: "**" # 전체 파일 - owner: ec2-user - group: ec2-user + owner: ubuntu + group: ubuntu # 실행될 스크립트 hooks: @@ -21,4 +21,4 @@ hooks: ApplicationStart: - location: deploy.sh timeout: 60 - runas: ec2-user + runas: ubuntu diff --git a/docker/docker-compose.blue.yml b/docker/docker-compose.blue.yml index c15aea13..4cf02b62 100644 --- a/docker/docker-compose.blue.yml +++ b/docker/docker-compose.blue.yml @@ -1,10 +1,6 @@ #blue version: '3' services: - redis: - image: redis - ports: - - "6379:6379" backend: build: . ports: @@ -12,5 +8,3 @@ services: container_name: yello-blue environment: - TZ=Asia/Seoul - depends_on: - - redis diff --git a/docker/docker-compose.green.yml b/docker/docker-compose.green.yml index 153237cf..21689730 100644 --- a/docker/docker-compose.green.yml +++ b/docker/docker-compose.green.yml @@ -1,10 +1,6 @@ #blue version: '3' services: - redis: - image: redis - ports: - - "6379:6379" backend: build: . ports: @@ -12,5 +8,3 @@ services: container_name: yello-green environment: - TZ=Asia/Seoul - depends_on: - - redis diff --git a/scripts/deploy.sh b/scripts/deploy.sh index ca5c88cd..1d2d9bae 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -1,18 +1,18 @@ #!/bin/bash -cd /home/ec2-user/app +cd /home/ubuntu/app DOCKER_APP_NAME=yello # BLUE 서버 체크 EXIST_BLUE=$(sudo docker-compose -p ${DOCKER_APP_NAME}-blue -f docker-compose.blue.yml ps | grep Up) -echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] 배포를 시작합니다." >> /home/ec2-user/deploy.log +echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] 배포를 시작합니다." >> /home/ubuntu/deploy.log # Redis 컨테이너가 실행 중인지 확인 REDIS_RUNNING=$(sudo docker ps -q -f "name=redis" -f "expose=6379") # Redis 컨테이너가 실행 중이면 일시적으로 종료 if [ -n "$REDIS_RUNNING" ]; then - echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Redis 컨테이너를 일시적으로 종료합니다." >> /home/ec2-user/deploy.log + echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Redis 컨테이너를 일시적으로 종료합니다." >> /home/ubuntu/deploy.log sudo docker-compose -p ${DOCKER_APP_NAME}-blue -f docker-compose.blue.yml stop redis sudo docker-compose -p ${DOCKER_APP_NAME}-green -f docker-compose.green.yml stop redis fi @@ -22,11 +22,11 @@ if [ -z "$EXIST_BLUE" ]; then REDIS_GREEN_RUNNING=$(sudo docker-compose -p ${DOCKER_APP_NAME}-green -f docker-compose.green.yml ps | grep redis) if [ -n "$REDIS_GREEN_RUNNING" ]; then - echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Green Redis 컨테이너를 종료합니다." >> /home/ec2-user/deploy.log + echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Green Redis 컨테이너를 종료합니다." >> /home/ubuntu/deploy.log sudo docker-compose -p ${DOCKER_APP_NAME}-green -f docker-compose.green.yml stop redis fi - echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Blue 배포를 시작합니다." >> /home/ec2-user/deploy.log + echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Blue 배포를 시작합니다." >> /home/ubuntu/deploy.log sudo docker-compose -p ${DOCKER_APP_NAME}-blue -f docker-compose.blue.yml up -d --build sleep 30 @@ -35,10 +35,10 @@ if [ -z "$EXIST_BLUE" ]; then if [ -z "$BLUE_HEALTH" ]; then sudo ./slack_blue.sh else - echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Green 서버를 종료합니다." >> /home/ec2-user/deploy.log + echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Green 서버를 종료합니다." >> /home/ubuntu/deploy.log sudo docker-compose -p ${DOCKER_APP_NAME}-green -f docker-compose.green.yml down sudo docker image prune -af - echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Green 서버를 종료했습니다." >> /home/ec2-user/deploy.log + echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Green 서버를 종료했습니다." >> /home/ubuntu/deploy.log fi # BLUE가 실행중이면 GREEN up @@ -46,11 +46,11 @@ else REDIS_BLUE_RUNNING=$(sudo docker-compose -p ${DOCKER_APP_NAME}-blue -f docker-compose.blue.yml ps | grep redis) if [ -n "REDIS_BLUE_RUNNING" ]; then - echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Blue Redis 컨테이너를 종료합니다." >> /home/ec2-user/deploy.log + echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Blue Redis 컨테이너를 종료합니다." >> /home/ubuntu/deploy.log sudo docker-compose -p ${DOCKER_APP_NAME}-blue -f docker-compose.blue.yml stop redis fi - echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Green 배포가 시작됩니다." >> /home/ec2-user/deploy.log + echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Green 배포가 시작됩니다." >> /home/ubuntu/deploy.log sudo docker-compose -p ${DOCKER_APP_NAME}-green -f docker-compose.green.yml up -d --build sleep 30 @@ -59,21 +59,21 @@ else if [ -z "$GREEN_HEALTH" ]; then sudo ./slack_green.sh else - echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Blue 서버를 종료합니다." >> /home/ec2-user/deploy.log + echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Blue 서버를 종료합니다." >> /home/ubuntu/deploy.log sudo docker-compose -p ${DOCKER_APP_NAME}-blue -f docker-compose.blue.yml down sudo docker image prune -af - echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Blue 서버를 종료했습니다." >> /home/ec2-user/deploy.log + echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Blue 서버를 종료했습니다." >> /home/ubuntu/deploy.log fi fi # Redis 컨테이너가 종료되었을 경우 다시 시작 if [ -n "$REDIS_RUNNING" ]; then - echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Redis 컨테이너를 다시 시작합니다." >> /home/ec2-user/deploy.log + echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Redis 컨테이너를 다시 시작합니다." >> /home/ubuntu/deploy.log sudo docker-compose -p ${DOCKER_APP_NAME}-blue -f docker-compose.blue.yml start redis sudo docker image prune -af - echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Redis 컨테이너를 다시 시작했습니다." >> /home/ec2-user/deploy.log + echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] Redis 컨테이너를 다시 시작했습니다." >> /home/ubuntu/deploy.log fi -echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] 배포를 종료합니다." >> /home/ec2-user/deploy.log -echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] 배포 프로세스 완료 =====================" >> /home/ec2-user/deploy.log -echo >> /home/ec2-user/deploy.log +echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] 배포를 종료합니다." >> /home/ubuntu/deploy.log +echo "[$(date +%Y)-$(date +%m)-$(date +%d) $(date +%H):$(date +%M):$(date +%S)] 배포 프로세스 완료 =====================" >> /home/ubuntu/deploy.log +echo >> /home/ubuntu/deploy.log