Skip to content

hotfix : deploy 용 #14

hotfix : deploy 용

hotfix : deploy 용 #14

Workflow file for this run

name: Deploy fast-api-server (FastAPI)
on:
push:
branches:
- main
jobs:
deploy-fast-api-server:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: ✅ Checkout FastAPI 코드
uses: actions/checkout@v3
- name: 🔧 Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: 💾 Docker 캐시 설정
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: 🐳 Docker Hub 로그인
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: ⚙️ FastAPI 이미지 빌드 & 푸시 (Buildx + 캐시 적용)
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/fast-api-server:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: 🚀 EC2에 접속해서 fast-api-server 재시작
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_KEY }}
script: |
cd ~/my-app
echo "${{ secrets.ENV_FILE }}" > .env
docker compose pull fast-api-server
docker compose up -d fast-api-server