From 47ed1d249667fd0f611d123f1ca12fc40ead7841 Mon Sep 17 00:00:00 2001 From: frombunny Date: Fri, 22 Aug 2025 15:38:14 +0900 Subject: [PATCH 1/3] =?UTF-8?q?:green=5Fheart:=20ci:=20CI/CD=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cicd.yml | 65 ++++++++++++++++++++++++++++++++++++++ Dockerfile | 9 ++++++ 2 files changed, 74 insertions(+) create mode 100644 .github/workflows/cicd.yml create mode 100644 Dockerfile diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml new file mode 100644 index 0000000..bb3170e --- /dev/null +++ b/.github/workflows/cicd.yml @@ -0,0 +1,65 @@ +name: CI/CD with FastAPI + +on: + pull_request: + branches: ["main"] + push: + branches: ["main"] + workflow_dispatch: + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +env: + IMAGE: ${{ secrets.DOCKER_USERNAME }}/menu-ai + +jobs: + docker-build-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build & Push Docker Image + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + tags: | + ${{ env.IMAGE }}:latest + ${{ env.IMAGE }}:${{ github.sha }} + + deploy: + name: Deploy to Server + needs: docker-build-push + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + + steps: + - name: Deploy via SSH + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USER }} + key: ${{ secrets.PRIVATE_KEY }} + script: | + docker pull ${{ env.IMAGE }}:latest + docker stop menu-ai || true + docker rm menu-ai || true + docker run -d --name menu-ai \ + -p 8000:8000 \ + -e OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} \ + -e OPENAI_MODEL=${{ secrets.OPENAI_MODEL }} \ + ${{ env.IMAGE }}:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7a7cca2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.11-slim + +WORKDIR /app + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] From 0c162f74020d4e113ff54ed9ac1c048b575acb61 Mon Sep 17 00:00:00 2001 From: frombunny Date: Fri, 22 Aug 2025 15:40:04 +0900 Subject: [PATCH 2/3] =?UTF-8?q?:memo:=20docs:=20pr=20=ED=85=9C=ED=94=8C?= =?UTF-8?q?=EB=A6=BF=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/{PULL_REQUEST_TEMPLATE.md.md => PULL_REQUEST_TEMPLATE.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{PULL_REQUEST_TEMPLATE.md.md => PULL_REQUEST_TEMPLATE.md} (100%) diff --git a/.github/PULL_REQUEST_TEMPLATE.md.md b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from .github/PULL_REQUEST_TEMPLATE.md.md rename to .github/PULL_REQUEST_TEMPLATE.md From bd85565e08edff981507abefdbe94953617f14b8 Mon Sep 17 00:00:00 2001 From: frombunny Date: Fri, 22 Aug 2025 15:42:25 +0900 Subject: [PATCH 3/3] =?UTF-8?q?:recycle:=20refactor:=20requirements.txt=20?= =?UTF-8?q?=EB=AC=B8=EC=84=9C=20=EC=9C=84=EC=B9=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/requirements.txt => requirements.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/requirements.txt => requirements.txt (100%) diff --git a/app/requirements.txt b/requirements.txt similarity index 100% rename from app/requirements.txt rename to requirements.txt