From 615e6f3fc45e2fdb5f711acc8e2223049bfe1b1a Mon Sep 17 00:00:00 2001 From: suhyun Date: Sat, 9 Sep 2023 21:04:13 +0900 Subject: [PATCH] Setting: EC2 setting --- .github/workflows/cicd.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 90fc963..8d6e110 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -120,7 +120,7 @@ jobs: - name: Deploy Docker Compose to EC2 uses: appleboy/ssh-action@v0.1.4 with: - host: ${{ secrets.EC2_HOST }} + host: ${{ secrets.EC2_HOST }} username: ${{ secrets.EC2_USERNAME }} key: ${{ secrets.EC2_PRIVATE_KEY }} envs: GITHUB_SHA @@ -129,6 +129,13 @@ jobs: # Navigate to the directory containing docker-compose.yml cd $HOME + + docker-compose down --rmi all + + # Stop and remove specific containers (except nginx) + docker-compose stop backend redis + docker-compose rm -f + docker-compose rmi $(docker images -f "dangling=true" -q) # Log in to Amazon ECR again (in case the login is expired after image removal) aws ecr get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin ${{ env.AWS_ECR_REGISTRY }}