From 3c704f27a25aa45e7b0ab3e20db6776d12e3b0af Mon Sep 17 00:00:00 2001 From: dldmsql Date: Tue, 7 Feb 2023 22:28:20 +0900 Subject: [PATCH 1/2] =?UTF-8?q?#34=20PROD2=20=EC=84=9C=EB=B2=84=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20=EC=9E=91=EC=97=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CD_Prod.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CD_Prod.yml b/.github/workflows/CD_Prod.yml index 2dc93b5..dd119c6 100644 --- a/.github/workflows/CD_Prod.yml +++ b/.github/workflows/CD_Prod.yml @@ -68,8 +68,8 @@ jobs: docker tag myongsik_prod1 ${{ secrets.DOCKER_USERNAME }}/myongsik docker push ${{ secrets.DOCKER_USERNAME }}/myongsik - # 9) Deploy - - name: Deploy + # 9) Deploy (PROD1) + - name: Deploy (PROD1) uses: appleboy/ssh-action@master with: host: ${{ secrets.EC2_HOST }} @@ -81,3 +81,17 @@ jobs: sudo docker pull ${{ secrets.DOCKER_USERNAME }}/myongsik sudo docker run -d --name myongsik_prod1 -v /etc/localtime:/etc/localtime:ro -e JAVA_OPTS=-Djasypt.encryptor.password=${{ secrets.YML_PASSWORD }} -e TZ=Asia/Seoul -e ENVIRONMENT_VALUE=-Dspring.profiles.active=prod -p 8085:8080 ${{ secrets.DOCKER_USERNAME }}/myongsik:latest docker rmi -f $(docker images -f "dangling=true" -q) + + # 10) Deploy (PROD2) + - name: Deploy (PROD2) + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.EC2_HOST_PROD2 }} + username: ${{ secrets.EC2_USERNAME }} + key: ${{ secrets.EC2_KEY }} + script: | + docker stop myongsik_prod2 + docker rm myongsik_prod2 + sudo docker pull ${{ secrets.DOCKER_USERNAME }}/myongsik + sudo docker run -d --name myongsik_prod2 -v /etc/localtime:/etc/localtime:ro -e JAVA_OPTS=-Djasypt.encryptor.password=${{ secrets.YML_PASSWORD }} -e TZ=Asia/Seoul -e ENVIRONMENT_VALUE=-Dspring.profiles.active=prod -p 8085:8080 ${{ secrets.DOCKER_USERNAME }}/myongsik:latest + docker rmi -f $(docker images -f "dangling=true" -q) From c07c65a473bbe0475e782a61e39e2b4b09f3ff13 Mon Sep 17 00:00:00 2001 From: dldmsql Date: Tue, 7 Feb 2023 22:58:26 +0900 Subject: [PATCH 2/2] =?UTF-8?q?#34=20PROD2=20=EC=84=9C=EB=B2=84=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20=EC=8B=9C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CD_Prod.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CD_Prod.yml b/.github/workflows/CD_Prod.yml index dd119c6..bfb5699 100644 --- a/.github/workflows/CD_Prod.yml +++ b/.github/workflows/CD_Prod.yml @@ -64,8 +64,7 @@ jobs: - name: docker build and push run: | docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} - docker build -f Dockerfile -t myongsik_prod1 . - docker tag myongsik_prod1 ${{ secrets.DOCKER_USERNAME }}/myongsik + docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/myongsik . docker push ${{ secrets.DOCKER_USERNAME }}/myongsik # 9) Deploy (PROD1) @@ -90,6 +89,7 @@ jobs: username: ${{ secrets.EC2_USERNAME }} key: ${{ secrets.EC2_KEY }} script: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} docker stop myongsik_prod2 docker rm myongsik_prod2 sudo docker pull ${{ secrets.DOCKER_USERNAME }}/myongsik