Skip to content

hike-lab/juso-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

juso-chatbot

설치방법

.env 파일 설정

  • .env.example 파일 복제 후 .env 파일 생성
  • 그 외 key 값은 개별 문의

backend 설정

  • cd backend

  • python 가상 환경 생성, requirements.txt 설치

    • 3.12.4 이상 환경 필수
    # 1. generate python bubble
    python -m venv env
    
    # 2. activate
    source env/bin/activate  # mac
    env\Scripts\activate.bat  # window
    
    # 3. install dependencies
    pip install -r requirements.txt
    
    # 4. deactivate bubble
    # deactivate

데이터베이스 설정

  • chroma폴더의 chroma.sqlite3.zip 파일 압축 해제
  • gitignore 되어 있어서 push해도 깃헙에 업로드 안됨 (100mb 이상 파일이므로)

frontend 설정

  • cd frontend
  • frontend 폴더 내부의 .env 파일에 VITE_API_URL=http://localhost:5000 설정
  • npm install
  • npm run dev
    • localhost:3000으로 접속

Deploy 방법

Docker compose로 실행

  • 별 이상 없다면 docker-compose up --build -d만 해주면 됨
docker-compose down # 실행 중인 모든 컨테이터, 볼륨, 이미지 삭제
docker-compose up --build -d # 이미지 설치후 백그라운드에서 실행
# docker system prune
brew services restart nginx

백엔드/프론트엔드 개별적으로 실행

Backend 설정

  • main.py에서 CORS 허용되는 도메인은 localhost:3000hike.cau.ac.kr으로 설정함
  • gunicorn으로 실행하는 경우 debug=False가 되므로 개발모드 실행은 python main.py 해주면 될 듯
# source env/bin/activate
# pip install -r requirements.txt
cd backend
gunicorn -b 0.0.0.0:5000 main:app

frontend 설정

하위경로 추가

  • /chatbot이란 하위경로로 도메인을 붙이기 위해 nuxt.config.ts에 하위경로 설정
app: {
  baseURL: '/chatbot/',
},

nginx 설정

  • CORS 에러, proxy 등 설정
location /chatbot/ {
            # 비밀번호 설정
            auth_basic "Security";
            auth_basic_user_file /usr/local/etc/nginx/.htpasswd;

            # proxy 설정
            proxy_pass http://localhost:3000/chatbot/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;

            # WebSocket 지원을 위한 설정 (필요한 경우)
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";

            # CORS 헤더 설정
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Allow-Credentials true;
            add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
            add_header Access-Control-Allow-Headers 'Origin, Content-Type, Accept, Authorization';
        }

frontend 설정

  • frontend 폴더 내부의 .env 파일에 VITE_API_URL=http://165.194.115.109:5000 설정
  • 로컬에서 실행하는 백엔드와 연결하고 싶다면 VITE_API_URL=http://localhost:5000로 변경
cd frontend
npm run build
node .output/server/index.mjs

Releases

No releases published

Packages

No packages published