1- name : Build & Deploy Spike (Flask-only → GHCR → EC2)
1+ name : Build & Deploy Spike (GHCR → EC2)
22
33on :
44 push :
@@ -13,18 +13,19 @@ jobs:
1313 runs-on : ubuntu-latest
1414 steps :
1515 - uses : actions/checkout@v4
16+
1617 - uses : docker/setup-buildx-action@v3
1718 - uses : docker/login-action@v3
1819 with :
1920 registry : ghcr.io
2021 username : ${{ github.actor }}
2122 password : ${{ secrets.GITHUB_TOKEN }}
2223
23- - name : Build & Push spike image (root Dockerfile)
24+ - name : Build & Push spike image
2425 uses : docker/build-push-action@v6
2526 with :
26- context : . # 루트 컨텍스트
27- file : ./Dockerfile # 루트 Dockerfile 사용
27+ context : .
28+ file : ./Dockerfile
2829 push : true
2930 tags : |
3031 ghcr.io/dmu-debugvisual/debugvisual-spike:latest
4041 sed -i 's/\r$//' ~/.ssh/id_rsa
4142 chmod 600 ~/.ssh/id_rsa
4243 ssh-keyscan -H "$HOST" >> ~/.ssh/known_hosts
43- ssh "$USER@$HOST" "\
44- docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} && \
45- cd ~/apps/debugvisual && \
46- docker compose pull && docker compose up -d && \
47- docker image prune -af || true"
44+
45+ ssh "$USER@$HOST" "bash -s" << 'EOSSH'
46+ set -e
47+ LOCK=/tmp/debugvisual.deploy.lock
48+ (
49+ flock -n 9 || { echo 'Another deploy is running. Skip.'; exit 0; }
50+ cd ~/apps/debugvisual
51+ docker logout ghcr.io || true # 익명 pull 강제
52+ docker compose pull --ignore-pull-failures flask-server
53+ docker compose up -d --wait --remove-orphans flask-server
54+ docker image prune -af || true
55+ curl -skI https://api.zivorp.com/healthz | head -n1
56+ ) 9>$LOCK
57+ EOSSH
0 commit comments