# 使用 Python 基礎映像 FROM python:3.11-slim # 設定工作目錄 WORKDIR /app # 安裝系統相依套件 RUN apt-get update && apt-get install -y \ gcc \ g++ \ git \ && rm -rf /var/lib/apt/lists/* # 複製需求檔並安裝 Python 套件 COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # 複製應用程式碼 COPY . . # 建立非 root 使用者(Hugging Face Spaces 要求) RUN useradd -m -u 1000 user USER user # 暴露預設 Hugging Face Spaces 埠口 EXPOSE 7860 # 啟動 Gradio 應用 CMD ["python", "app.py"]