Skip to content

Commit

Permalink
♻️ refactor: Update EC2 deployment process
Browse files Browse the repository at this point in the history
Changed the Docker container handling logic in the deployment script. Now using 'docker stop' and 'docker rm' commands to ensure clean deployment by stopping and removing the existing container before deploying the new one. This update enhances the reliability of the deployment process.

Related issue: #30
  • Loading branch information
yuminn-k authored Mar 6, 2024
1 parent 54f86d7 commit 2a1476a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ jobs:
- name: Execute Deployment Commands on EC2
run: |
ssh -i ~/.ssh/id_rsa ubuntu@${{ env.EC2_IP }} "
sudo docker pull ghcr.io/yju-okura/minori_gin:latest;
sudo docker rm -f minori_gin || true;
docker pull ghcr.io/yju-okura/minori_gin:latest;
docker stop minori_gin;
docker rm minori_gin;
IMAGE_ID=$(sudo docker images -q ghcr.io/yju-okura/minori_gin:latest | head -n 1);
if [ ! -z \"$IMAGE_ID\" ]; then
sudo docker images -q | grep -v $IMAGE_ID | xargs -r sudo docker rmi;
docker images -q | grep -v $IMAGE_ID | xargs -r sudo docker rmi;
fi;
sudo docker run -d -p 80:8080 --env-file /volume/.env --restart always --name minori_gin ghcr.io/yju-okura/minori_gin:latest"
docker run -d -p 80:8080 --env-file /volume/.env --restart always --name minori_gin ghcr.io/yju-okura/minori_gin:latest"

0 comments on commit 2a1476a

Please sign in to comment.