Spaces:
Sleeping
Sleeping
Download Dockerfile from minchun/II_SpectraEngine: direct link, hf CLI and curl.
- Browser
- Download file 1.83 kB
-
https://huggingface.co/spaces/minchun/II_SpectraEngine/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/minchun/II_SpectraEngine/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/minchun/II_SpectraEngine/resolve/main/Dockerfile
1.83 kB
| # Hugging Face Space(Docker SDK)用的容器設定。 | |
| # | |
| # 為什麼不用 Gradio SDK:HF 免費層級的 Gradio SDK Space 現在預設跑在 | |
| # ZeroGPU 上(HF 平台政策),啟動時要求偵測到 @spaces.GPU 標記的函式, | |
| # 本專案是純 CPU 應用(scikit-learn/scipy/matplotlib,完全不用 GPU), | |
| # 沒有這種函式,Gradio SDK 會直接啟動失敗。改用 Docker SDK:由這份 | |
| # Dockerfile 自己控制執行環境,不吃 Gradio SDK 的 ZeroGPU 預設規則, | |
| # 一樣可以跑在免費的 CPU 硬體上。 | |
| FROM python:3.11-slim | |
| # fonts-noto-cjk:matplotlib 圖表(特徵重要性、分群圖等)標題與座標軸 | |
| # 都是中文,容器內建的 Linux 沒有任何中文字型,沒裝的話中文會變成方框。 | |
| # app_agent.py 的 _find_cjk_font() 本來就把 "Noto Sans CJK TC"/ | |
| # "Noto Sans CJK SC" 排在候選字型清單裡(原本是留給 Linux 部署用的), | |
| # 裝了這個套件就能直接吃到,不用改程式碼。 | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| fonts-noto-cjk \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # 先只複製 requirements 檔案再裝套件,Docker layer cache 才會生效—— | |
| # 之後只改程式碼、沒改依賴套件時,重新建置不用重跑 pip install。 | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade pip \ | |
| && pip install --no-cache-dir -r requirements.txt \ | |
| && pip install --no-cache-dir python-dotenv | |
| COPY . . | |
| # HF Docker Space 的容器以非 root、UID 1000 執行;sessions/ 是執行期才會 | |
| # 建立與寫入的資料夾(session 上傳檔、分析產出),這裡先建好並開放寫入 | |
| # 權限,避免執行期因權限不足寫入失敗。 | |
| RUN mkdir -p sessions && chmod -R 777 sessions | |
| EXPOSE 7860 | |
| CMD ["python", "app.py"] | |