Spaces:
Sleeping
Sleeping
| # 使用官方 Python 映像檔作為基礎 | |
| FROM python:3.12.3-slim | |
| # 設定工作目錄 | |
| WORKDIR /app | |
| # 將 requirements.txt 複製到工作目錄中 | |
| COPY requirements.txt . | |
| # 更新 pip 並安裝所需的套件 | |
| # 我們需要 git 來安裝特定版本的套件 (如果有的話) | |
| # 以及 build-essential 來編譯某些相依套件 | |
| RUN apt-get update && apt-get install -y git build-essential && \ | |
| pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # 將專案中的所有檔案複製到工作目錄中 | |
| COPY . . | |
| # 設定環境變數 (這些應該在 Hugging Face Space 的 secrets 中設定) | |
| # ENV VERIFY_TOKEN="your_verify_token" | |
| # ENV PAGE_ACCESS_TOKEN="your_page_access_token" | |
| # ENV OPENAI_API_KEY="your_openai_api_key" | |
| # 開放應用程式運行的埠口 | |
| EXPOSE 8000 | |
| # 使用 Gunicorn 啟動應用程式 | |
| # --bind 0.0.0.0:8000 讓它可以從外部被存取 | |
| # --workers 1 對於免費方案,一個 worker 通常是比較穩定的選擇 | |
| # --timeout 120 增加超時時間,以應對可能的模型載入或長時間的請求 | |
| CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "1", "--timeout", "120", "app:app"] |