66
77permissions :
88 contents : read
9- packages : write
109
1110jobs :
1211 deploy :
@@ -50,32 +49,15 @@ jobs:
5049 cp $(ls build/libs/*.jar | grep -v plain | head -n 1) app.jar
5150
5251 # --------------------------
53- # 5) Docker 빌드 & ghcr.io 푸시
52+ # 5) Docker 이미지 빌드 → tar 저장
5453 # --------------------------
55- - name : Set up Docker Buildx
56- uses : docker/setup-buildx-action@v3
57-
58- - name : Log in to ghcr.io
59- uses : docker/login-action@v3
60- with :
61- registry : ghcr.io
62- username : ${{ github.actor }}
63- password : ${{ secrets.GITHUB_TOKEN }}
64-
65- - name : Build and push to ghcr.io
66- uses : docker/build-push-action@v6
67- with :
68- context : .
69- file : ./Dockerfile
70- push : true
71- tags : |
72- ghcr.io/${{ github.repository }}:latest
73- ghcr.io/${{ github.repository }}:${{ github.sha }}
74- cache-from : type=gha
75- cache-to : type=gha,mode=max
54+ - name : Build Docker image
55+ run : |
56+ docker build -t tinybite-server:latest .
57+ docker save tinybite-server:latest | gzip > tinybite-server.tar.gz
7658
7759 # --------------------------
78- # 6) 서버로 파일 전송 (SCP)
60+ # 6) SCP로 서버에 전송
7961 # --------------------------
8062 - name : Copy files to OCI server
8163 uses : appleboy/scp-action@master
@@ -84,13 +66,13 @@ jobs:
8466 username : ${{ secrets.SSH_USERNAME }}
8567 key : ${{ secrets.SSH_KEY }}
8668 port : 22
87- source : " .env,docker-compose.yml,nginx/"
69+ source : " tinybite-server.tar.gz, .env,docker-compose.yml,nginx/"
8870 target : " /home/ubuntu/tinybite/"
8971
9072 # --------------------------
91- # 7) OCI 서버 배포 (SSH)
73+ # 7) 서버에서 이미지 load & 실행
9274 # --------------------------
93- - name : Deploy to OCI server
75+ - name : Deploy on OCI server
9476 uses : appleboy/ssh-action@master
9577 with :
9678 host : ${{ secrets.SSH_HOST }}
@@ -101,20 +83,14 @@ jobs:
10183 set -e
10284 cd /home/ubuntu/tinybite
10385
104- # ghcr.io 로그인
105- echo "${{ secrets.GITHUB_TOKEN }}" \
106- | docker login ghcr.io \
107- -u ${{ github.actor }} \
108- --password-stdin
109-
110- # 최신 이미지 pull
111- export APP_IMAGE="ghcr.io/${{ github.repository }}:latest"
112- docker compose pull
86+ echo "📦 이미지 로드 중..."
87+ docker load < tinybite-server.tar.gz
11388
114- # 새 컨테이너 실행
89+ echo "🚀 컨테이너 재시작..."
11590 docker compose up -d --remove-orphans
11691
117- # 이미지 정리
92+ echo "🧹 정리 중..."
93+ rm -f tinybite-server.tar.gz
11894 docker image prune -f
11995
120- echo "✅ 배포 완료: $APP_IMAGE "
96+ echo "✅ 배포 완료"
0 commit comments