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
27 changes: 27 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Continuous Deployment

on:
push:
branches: [ main ]
workflow_dispatch: # 수동 트리거 옵션 추가

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Deploy to production server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.PROD_HOST }}
username: ${{ secrets.PROD_USERNAME }}
key: ${{ secrets.PROD_SSH_KEY }}
script: |
cd ~/ai-server-test
git remote update
git checkout main
git pull origin main
make # Makefile을 통한 배포
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Continuous Integration

on:
push:
branches: [ develop ]
pull_request:
branches: [ develop, main ]

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Install Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Build with docker-compose
run: docker-compose -f docker-compose.test.yml build

# - name: Move cache
# run: |
# rm -rf /tmp/.buildx-cache
# mv /tmp/.buildx-cache-new /tmp/.buildx-cache

- name: Run tests
run: |
docker-compose -f docker-compose.test.yml up -d

# 잠시 대기
sleep 10

# 간단한 상태 확인
curl -f http://localhost:80/health || exit 1

# 컨테이너 종료
docker-compose -f docker-compose.test.yml down

- name: Cleanup
if: always()
run: docker-compose -f docker-compose.test.yml down -v
18 changes: 0 additions & 18 deletions .github/workflows/github-actions-demo.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.env
__pycache__
data
vectordb
tmux-script/
25 changes: 25 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

services:
ai-server:
init: true
container_name: ai-server
environment:
OPENAI_API_KEY: "testapikey"
build:
context: ./srcs/ai-server
dockerfile: Dockerfile # 아래에 Dockerfile 예시 참고
volumes:
- ./srcs/ai-server/project:/project
ports:
- "80:8000" # 호스트의 8000 포트를 컨테이너의 8000 포트

ai-preprocessing:
init: true
container_name: ai-preprocessing
environment:
OPENAI_API_KEY: "testapikey"
build:
context: ./srcs/ai-preprocessing
dockerfile: Dockerfile # 아래에 Dockerfile 예시 참고
volumes:
- ./srcs/ai-preprocessing/project:/project
8 changes: 7 additions & 1 deletion srcs/ai-preprocessing/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM jeongtj/langchain-rag
# FROM jeongtj/langchain-rag
FROM python:3.11-slim

WORKDIR /project

COPY ./requirements.txt /project/

RUN pip install -r requirements.txt


CMD ["tail", "-f", "/dev/null"]
13 changes: 13 additions & 0 deletions srcs/ai-preprocessing/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pandas
tqdm
python-dotenv
langchain-community
langchain-openai
langchain-core
faiss-cpu
langsmith
cohere
networkx
requests
langchain
langchainhub
11 changes: 8 additions & 3 deletions srcs/ai-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
FROM jeongtj/langchain-rag
# FROM jeongtj/langchain-rag
FROM python:3.11-slim

WORKDIR /project

COPY requirements.txt /project/
COPY entrypoint.sh /home/entrypoint.sh
RUN apt update && apt install -y curl

COPY ./requirements.txt /project/
COPY ./entrypoint.sh /home/entrypoint.sh

RUN sed -i 's/\r//' /home/entrypoint.sh

RUN pip install -r requirements.txt
RUN chmod +x /home/entrypoint.sh
Expand Down
34 changes: 33 additions & 1 deletion srcs/ai-server/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
#!/bin/bash
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload

# 환경 변수에 따라 실행 모드 결정
if [ "$ENV" = "test" ]; then
echo "Running in TEST mode"

# 백그라운드에서 uvicorn 실행
uvicorn app.main:app --host 0.0.0.0 --port 8000 &
UVICORN_PID=$!

# 서버가 시작될 때까지 대기
echo "Waiting for server to start..."
sleep 5

# 서버가 실행 중인지 확인
if curl -s http://localhost:8000/health > /dev/null; then
echo "Server is running correctly"
# 서버 종료 - 더 강력한 종료 시그널 사용
echo "Shutting down server..."
kill -9 $UVICORN_PID
wait $UVICORN_PID 2>/dev/null || true
echo "Server shutdown complete"
exit 0
else
echo "Server failed to start properly"
kill -9 $UVICORN_PID
wait $UVICORN_PID 2>/dev/null || true
exit 1
fi
else
# 프로덕션 모드 실행
echo "Running in PRODUCTION mode"
uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4
fi
4 changes: 4 additions & 0 deletions srcs/ai-server/project/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@
@app.get("/")
async def root():
return {"message": "Travel Agent API is running"}

@app.get("/health")
async def root():
return {"status": "ok"}
4 changes: 4 additions & 0 deletions srcs/ai-server/project/app/utils/vectordb.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def load_vectordb(index_name: str):
project_root = Path(__file__).parent.parent.parent
vectordb_path = project_root / "vectordb" / index_name

if not vectordb_path.exists():
index_name = "dummy_finder"
vectordb_path = project_root / "vectordb" / index_name

if not vectordb_path.exists():
raise FileNotFoundError(f"Vector DB not found at {vectordb_path}")

Expand Down
Binary file not shown.
Binary file not shown.
15 changes: 14 additions & 1 deletion srcs/ai-server/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
uvicorn
fastapi
fastapi
pandas
tqdm
python-dotenv
langchain-community
langchain-openai
langchain-core
faiss-cpu
langsmith
cohere
networkx
requests
langchain
langchainhub