Update Dockerfile #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build & Deploy Spike (Flask-only → GHCR → EC2) | |
| on: | |
| push: | |
| branches: [ main ] | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build-push-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build & Push spike image (root Dockerfile) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . # 루트 컨텍스트 | |
| file: ./Dockerfile # 루트 Dockerfile 사용 | |
| push: true | |
| tags: | | |
| ghcr.io/dmu-debugvisual/debugvisual-spike:latest | |
| ghcr.io/dmu-debugvisual/debugvisual-spike:${{ github.sha }} | |
| - name: Deploy on EC2 (compose pull/up) | |
| env: | |
| HOST: ${{ secrets.EC2_HOST }} | |
| USER: ${{ secrets.EC2_USER }} | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.EC2_KEY }}" > ~/.ssh/id_rsa | |
| sed -i 's/\r$//' ~/.ssh/id_rsa | |
| chmod 600 ~/.ssh/id_rsa | |
| ssh-keyscan -H "$HOST" >> ~/.ssh/known_hosts | |
| ssh "$USER@$HOST" "\ | |
| docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} && \ | |
| cd ~/apps/debugvisual && \ | |
| docker compose pull && docker compose up -d && \ | |
| docker image prune -af || true" |