Skip to content

Commit

Permalink
[CICD] 기존 포트 확인 및 종료 후 재시도 스크립트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
EunbeenDev committed Jan 8, 2025
1 parent ee6caad commit 51f7360
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,18 @@ jobs:
ssh -o StrictHostKeyChecking=no -T -i ~/.ssh/id_rsa ubuntu@${{ secrets.EC2_PUBLIC_IP }} << 'EOF'
aws ecr get-login-password --region ${{ env.AWS_REGION }} | sudo docker login --username AWS --password-stdin $(aws ecr describe-repositories --repository-names ${{ env.ECR_REPOSITORY }} --query "repositories[0].repositoryUri" --output text)
# 기존 프로세스 확인 및 종료
if sudo lsof -i:8080; then
echo "Port 8080 is in use. Stopping process..."
sudo kill -9 $(sudo lsof -t -i:8080) || true
else
echo "Port 8080 is free."
fi
# Docker 이미지 Pull
sudo docker pull $(aws ecr describe-repositories --repository-names ${{ env.ECR_REPOSITORY }} --query "repositories[0].repositoryUri" --output text):${{ github.sha }}
# 기존 컨테이너 중지 및 제거
sudo docker stop ${{ env.DOCKER_IMAGE_NAME }} || true
sudo docker rm ${{ env.DOCKER_IMAGE_NAME }} || true
# 새 컨테이너 실행
sudo docker run -d -p 8080:8080 --name ${{ env.DOCKER_IMAGE_NAME }} $(aws ecr describe-repositories --repository-names ${{ env.ECR_REPOSITORY }} --query "repositories[0].repositoryUri" --output text):${{ github.sha }}
EOF
Expand Down

0 comments on commit 51f7360

Please sign in to comment.