# 選擇輕量級的 Python 基底映像 FROM python:3.10-slim # 設定工作目錄 WORKDIR /app # 安裝中文字型以供 Pillow 使用 RUN apt-get update && apt-get install -y fonts-noto-cjk && rm -rf /var/lib/apt/lists/* # 複製並安裝依賴清單 COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # 複製專案內所有檔案到容器中 COPY . . # 建立必要的資料夾 RUN mkdir -p data static # 賦予資料夾讀寫權限 (Hugging Face 環境需要) RUN chmod -R 777 data static # 暴露 7860 Port EXPOSE 7860 # 啟動 FastAPI 伺服器 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]