Skip to content

Commit

Permalink
Update server-cd.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
zzawang authored May 20, 2024
1 parent 188374f commit 1c067df
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/server-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ jobs:
run: |
cd ./be/issue-tracker
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:issue-tracker-dev .
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:issue-tracker-dev
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:latest
# 서버에 접속 후 Docker 이미지 가져와서 배포
- name: SSH into Server
Expand All @@ -57,15 +57,15 @@ jobs:
chmod 400 $HOME/key.pem
ssh -i $HOME/key.pem -o StrictHostKeyChecking=no ${EC2_USERNAME}@${EC2_HOST}
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:issue-tracker-dev
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:latest
# 기존에 실행 중인 컨테이너 중지 및 삭제
if [ $(sudo docker ps -q -f name=spring-server) ]; then
sudo docker stop spring-server
sudo docker rm spring-server
fi
# 새로운 컨테이너 실행
sudo docker run -d --name spring-server ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:issue-tracker-dev
sudo docker run -d -p 8080:8080 --name spring-server ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:latest
env:
EC2_USERNAME: ${{ secrets.EC2_USERNAME }}
EC2_HOST: ${{ secrets.EC2_HOST }}
Expand Down

0 comments on commit 1c067df

Please sign in to comment.