Skip to content

Commit

Permalink
fix : 도커 이미지 새로 생성하고 빌드하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jsilver01 committed Sep 23, 2024
1 parent 048dc95 commit fbda980
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/nodejs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
- name: Install dependencies
run: npm install

# - name: Build project
# run: npm run build
- name: Build project
run: npm run build # 프로젝트 빌드 명령 추가

docker-build:
runs-on: ubuntu-latest
Expand All @@ -54,22 +54,27 @@ jobs:
runs-on: ubuntu-latest
needs: docker-build
steps:
- name: deploy
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
username: ubuntu
host: ${{ secrets.WAS_HOST }}
key: ${{ secrets.PRIVATE_KEY }}
port: ${{ secrets.WAS_PORT }}
script: |
# 기존 컨테이너가 실행 중이면 종료하고 삭제
CONTAINER_ID=$(sudo docker ps -q --filter ancestor=${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }})
if [ ! -z "$CONTAINER_ID" ]; then
sudo docker stop $CONTAINER_ID
sudo docker rm $CONTAINER_ID
fi
sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }}
sudo docker run -d -p 9000:9000 ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }}
# 최신 이미지를 가져와서 실행
sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }}:latest
sudo docker run -d -p 9000:9000 ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }}:latest
# 로그 확인
sudo docker logs $(sudo docker ps -q --filter ancestor=${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }})
# 사용하지 않는 도커 이미지 제거
sudo docker image prune -f

0 comments on commit fbda980

Please sign in to comment.