From ccc8b1197bdbec187bb7574972bf801cfc2b8ef7 Mon Sep 17 00:00:00 2001 From: eedo_y Date: Thu, 18 Dec 2025 09:46:54 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=94=A8chore=20:=20=EC=A0=95=EC=A0=81?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=EA=B2=80=EC=82=AC=EA=B8=B0=20=EC=9D=98?= =?UTF-8?q?=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80=20-=20ruff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 6 ++++++ requirements.txt | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..31b1c33 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[tool.ruff] +target-version = "py310" +line-length = 88 + +[tool.ruff.lint] +select = [] diff --git a/requirements.txt b/requirements.txt index 8a9923f..5e40243 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,4 +15,6 @@ langchain-openai==0.1.25 langchain-chroma==0.1.4 tiktoken==0.7.0 -chromadb==0.5.3 \ No newline at end of file +chromadb==0.5.3 + +ruff==0.6.9 From baf9fd1fe0aa73dfbc48871bd0d85eb5a85edd91 Mon Sep 17 00:00:00 2001 From: eedo_y Date: Thu, 18 Dec 2025 09:49:18 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=94=A8chore=20:=20CICD=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=B4=ED=94=84=EB=9D=BC=EC=9D=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-test.yml | 50 +++++++++++++ .github/workflows/cicd-prod.yml | 123 ++++++++++++++++++++++++++++++++ 2 files changed, 173 insertions(+) create mode 100644 .github/workflows/ci-test.yml create mode 100644 .github/workflows/cicd-prod.yml diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml new file mode 100644 index 0000000..0a7134b --- /dev/null +++ b/.github/workflows/ci-test.yml @@ -0,0 +1,50 @@ +name: KTB 해커톤 14조 PR CI 파이프라인 + +on: + pull_request: + branches: [ "develop"] + +jobs: + + test: + runs-on: ubuntu-22.04 + if: success() + steps: + - name: 코드 체크아웃 + uses: actions/checkout@v4 + + - name: 파이썬 의존성 설치 + uses: actions/setup-python@v4 + with: + python-version: "3.10.19" + + - name: 의존성 설치 + run: pip install -r requirements.txt + + - name: Ruff 문법 오류 코드 검사 + run: ruff check . + + notify-discord: + runs-on: ubuntu-22.04 + needs: test + if: always() + steps: + - name: Discord 빌드 알림 + uses: sarisia/actions-status-discord@v1 + with: + webhook: ${{ secrets.DISCORD_WEBHOOK_AI_PR_URL }} + title: "${{ needs.build.result == 'success' && '✅' || '❌' }} 새로운 PR이 올라왔습니다!" + description: | + **제목**: ${{ github.event.pull_request.title }} + **작성자**: ${{ github.event.pull_request.user.login }} + **브랜치**: `${{ github.event.pull_request.base.ref }}`←`${{ github.event.pull_request.head.ref }}` + + **📊 빌드 결과**: + - 상태: ${{ needs.build.result == 'success' && '성공' || '실패' }} + + **🔗 링크**: + - [PR 확인하기](${{ github.event.pull_request.html_url }}) + + color: "${{ needs.build.result == 'success' && 65280 || 16711680 }}" + username: GitHub PR Bot + avatar_url: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png \ No newline at end of file diff --git a/.github/workflows/cicd-prod.yml b/.github/workflows/cicd-prod.yml new file mode 100644 index 0000000..7d269dc --- /dev/null +++ b/.github/workflows/cicd-prod.yml @@ -0,0 +1,123 @@ +name: KTB 해커톤 14조 CICD 파이프라인 + +on: + push: + branches: + - develop + +jobs: + test: + runs-on: ubuntu-22.04 + if: success() + steps: + - name: 코드 체크아웃 + uses: actions/checkout@v4 + + - name: 파이썬 의존성 설치 + uses: actions/setup-python@v4 + with: + python-version: "3.10.19" + + - name: 의존성 설치 + run: pip install -r requirements.txt + + - name: Ruff 문법 오류 코드 검사 + run: ruff check . + + # 테스트가 모두 통과했을 때만, 도커 이미지 빌드 + 푸시하기 + build-push-image: + runs-on: ubuntu-22.04 + needs: test + permissions: + contents: read + steps: + - name: 코드 체크아웃 + uses: actions/checkout@v4 + + - name: Docker Buildx 설정 + uses: docker/setup-buildx-action@v3 + + - name: Docker 로그인 + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + + - name: Docker 이미지 빌드 & Push + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKER_USERNAME }}/ktb-ai:latest + ${{ secrets.DOCKER_USERNAME }}/ktb-ai:${{ github.sha }} + + deploy: + runs-on: ubuntu-22.04 + needs: build-push-image + if: success() + steps: + - name: 체크아웃 + uses: actions/checkout@v4 + + - name: env 생성 + run: echo "${{ secrets.ENV }}" > .env + + - name: .env 파일 EC2에 전송 + uses: appleboy/scp-action@master + with: + host: ${{ secrets.EC2_PUBLIC_IP }} + username: ${{ secrets.SSH_USER }} + key: ${{ secrets.EC2_PRIVATE_KEY }} + source: ".env" # 방금 생성한 .env 파일 + target: "/home/ubuntu/app/" + + - name: docker-compose.yml 전달 + uses: appleboy/scp-action@master + with: + host: ${{ secrets.EC2_PUBLIC_IP }} + username: ${{ secrets.SSH_USER }} + key: ${{ secrets.EC2_PRIVATE_KEY }} + source: "docker-compose.yml" + target: "/home/ubuntu/app/" + + - name: EC2에서 docker-compose 실행 + uses: appleboy/ssh-action@master # SSH를 사용하여 EC2에서 명령 실행 + with: + host: ${{ secrets.EC2_PUBLIC_IP }} # EC2 퍼블릭 IP + username: ${{ secrets.SSH_USER }} + key: ${{ secrets.EC2_PRIVATE_KEY }} + script: | + # docker-compose 명령어 실행 + cd /home/ubuntu/app/ + docker compose pull + docker compose up -d fastapi + docker compose ps + + + notify-discord: + runs-on: ubuntu-22.04 + needs: deploy + if: always() + steps: + - name: Discord 배포 요청 알림 + uses: sarisia/actions-status-discord@v1 + with: + webhook: ${{ secrets.DISCORD_WEBHOOK_AI_URL }} + title: "${{ needs.deploy.result == 'success' && '✅' || '❌' }} develop 브랜치 배포 결과" + description: | + **커밋 메시지**: ${{ github.event.head_commit.message }} + **작성자**: ${{ github.event.pusher.name }} + **브랜치**: `${{ github.ref_name }}` + + **📊 빌드/배포 결과**: + - 상태: ${{ needs.deploy.result == 'success' && '성공' || '실패' }} + + **🔗 링크**: + - [커밋 확인하기](${{ github.event.head_commit.url }}) + + color: "${{ needs.deploy.result == 'success' && 65280 || 16711680 }}" + username: GitHub Deploy Bot + avatar_url: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png From d06fe33996557c2ca1049fd7546e32556d0285c5 Mon Sep 17 00:00:00 2001 From: eedo_y Date: Thu, 18 Dec 2025 09:49:28 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=94=A8chore=20:=20=EB=8F=84=EC=BB=A4?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EB=B0=8F=20=EB=8F=84=EC=BB=A4=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EC=A6=88=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 15 +++++++++++++++ docker-compose.yml | 10 ++++++++++ 2 files changed, 25 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bae36ea --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +# 파이썬 의존성 설치 +FROM python:3.10.19-slim + +# 파일 이동 +WORKDIR /app + +# 의존성 설치 +COPY requirements.txt requirements.txt +RUN pip install -r requirements.txt + +# 코드 복사 +COPY . . + +# fastAPI 실행하기 +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5b1ce24 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +services: + + fastapi: + image: wpgur07/ai:latest + container_name: zeusAI-app + ports: + - '8000:8000' + env_file: + - .env + restart: always \ No newline at end of file