Download Dockerfile from CJR61/papi_cc: direct link, hf CLI and curl.
- Browser
- Download file 1.3 kB
-
https://huggingface.co/spaces/CJR61/papi_cc/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/CJR61/papi_cc/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/CJR61/papi_cc/resolve/main/Dockerfile
1.3 kB
| # Use a lightweight Python base image | |
| FROM python:3.11-slim | |
| # Set the working directory | |
| WORKDIR /api | |
| COPY . . | |
| # 系統套件多裝 execstack | |
| # 結論:是 onnxruntime 的 .so 要求可執行 stack,導致 import 直接掛、容器秒退。 | |
| RUN apt-get update && apt-get install -y \ | |
| # libgl1-mesa-glx \ | |
| libgl1 \ | |
| libglx-mesa0 \ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # 安裝 patchelf,用來清掉 onnxruntime .so 的 exec-stack 旗標 | |
| RUN apt-get update && apt-get install -y --no-install-recommends patchelf \ | |
| && rm -rf /var/lib/apt/lists/* | |
| #########2025/0923 update######### | |
| # 找到 onnxruntime 的 .so 並清除 exec-stack(沒有就略過) | |
| RUN set -eux; \ | |
| so="$(find /usr/local/lib/python* -path '*/site-packages/onnxruntime/capi/onnxruntime_pybind11_state*.so' -print -quit 2>/dev/null)"; \ | |
| if [ -n "$so" ]; then \ | |
| patchelf --print-execstack "$so" || true; \ | |
| patchelf --clear-execstack "$so" || true; \ | |
| patchelf --print-execstack "$so" || true; \ | |
| fi | |
| #########2025/0923 update######### | |
| # Expose the application's port | |
| EXPOSE 7860 | |
| # Start the FastAPI application | |
| CMD ["python","-m","uvicorn","app.main:app","--host","0.0.0.0","--port","7860"] | |