Spaces:
Sleeping
Sleeping
Download Dockerfile from eishit32/UPNISO_API: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/spaces/eishit32/UPNISO_API/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/eishit32/UPNISO_API/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/eishit32/UPNISO_API/resolve/main/Dockerfile
1.15 kB
| # 1. Stable Python base | |
| FROM python:3.11-slim | |
| # 2. System dependencies (root) | |
| RUN apt-get update && apt-get install -y \ | |
| libgomp1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # 3. Create non-root user | |
| RUN useradd -m -u 1000 user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| WORKDIR $HOME/app | |
| # 4. Permissions | |
| RUN chown -R user:user $HOME | |
| USER user | |
| # 5. Environment (FIXED) | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| HF_HOME=$HOME/.cache/huggingface | |
| # 6. Copy requirements first (better caching) | |
| COPY --chown=user requirements.txt . | |
| # 7. Install deps (Torch first = correct move) | |
| RUN pip install --upgrade pip && \ | |
| pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu && \ | |
| pip install --no-cache-dir -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu | |
| # 8. Copy app code | |
| COPY --chown=user . . | |
| # 9. Pre-download model (zero cold start) | |
| RUN python -c "from sentence_transformers import CrossEncoder; CrossEncoder('cross-encoder/ms-marco-MiniLM-L6-v2')" | |
| # 10. Expose + run | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |