Skip to content

Commit

Permalink
[fix] 이전 컨테이너 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
wndlthsk committed Nov 7, 2024
1 parent 87eeecd commit ebdb234
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ jobs:
# 기존의 동일한 컨테이너를 중지 (블루/그린 중 다음 배포 타겟에 해당하는 컨테이너)
- name: Stop current docker container
run: |
echo "Stopping container inplace-${{ env.next_version }}"
sudo docker stop inplace-${{ env.next_version }} || true
sudo docker rm inplace-${{ env.next_version }} || true
echo "Stopping container inplace-${{ env.NEXT_VERSION }}"
sudo docker stop inplace-${{ env.NEXT_VERSION }} || true
sudo docker rm inplace-${{ env.NEXT_VERSION }} || true
# .env 파일 생성
- name: Create .env file
Expand All @@ -113,20 +113,31 @@ jobs:
# 다음 버전으로 새 컨테이너를 실행
- name: Run New Container on Next Version
run: |
echo "Running new container inplace-${{ env.next_version }}"
sudo docker run --name "inplace-${{ env.next_version }}" --rm -d -p ${{ env.port }}:8080 --env-file .env ${{ secrets.DOCKERHUB_USERNAME }}/inplace
echo "Running new container inplace-${{ env.NEXT_VERSION }}"
sudo docker run --name "inplace-${{ env.NEXT_VERSION }}" --rm -d -p ${{ env.port }}:8080 --env-file .env ${{ secrets.DOCKERHUB_USERNAME }}/inplace
# 로드 밸런서 타겟 그룹을 업데이트하여 트래픽을 새 컨테이너로 전환합니다.
- name: Update Load Balancer Target Group
run: |
TARGET_GROUP_ARN_BLUE="${{ secrets.TARGET_GROUP_ARN_8080 }}"
TARGET_GROUP_ARN_GREEN="${{ secrets.TARGET_GROUP_ARN_8081 }}"
if [[ "${{ env.next_version }}" == "blue" ]]; then
if [[ "${{ env.NEXT_VERSION }}" == "blue" ]]; then
aws elbv2 modify-listener --listener-arn ${{ secrets.LISTENER_ARN_443 }} --default-actions Type=forward,TargetGroupArn=$TARGET_GROUP_ARN_BLUE
else
aws elbv2 modify-listener --listener-arn ${{ secrets.LISTENER_ARN_443 }} --default-actions Type=forward,TargetGroupArn=$TARGET_GROUP_ARN_GREEN
fi
# 이전 컨테이너 정리
- name: Remove previous docker container
if: env.CURRENT_VERSION != 'none'
run: |
if [[ "${{ env.CURRENT_VERSION }}" != "none" ]]; then
echo "Removing previous container inplace-${{ env.CURRENT_VERSION }}"
sudo docker stop inplace-${{ env.CURRENT_VERSION }} || true
sudo docker rm inplace-${{ env.CURRENT_VERSION }} || true
else
echo "No active container to remove"
fi
# 미사용 이미지를 정리
- name: delete old docker image
Expand Down

0 comments on commit ebdb234

Please sign in to comment.