Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -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
123 changes: 123 additions & 0 deletions .github/workflows/cicd-prod.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:

fastapi:
image: wpgur07/ai:latest
container_name: zeusAI-app
ports:
- '8000:8000'
env_file:
- .env
restart: always
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[tool.ruff]
target-version = "py310"
line-length = 88

[tool.ruff.lint]
select = []
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ langchain-openai==0.1.25
langchain-chroma==0.1.4

tiktoken==0.7.0
chromadb==0.5.3
chromadb==0.5.3

ruff==0.6.9