Spaces:
Sleeping
Sleeping
| FROM python:3.11-slim | |
| # Install system dependencies for compiling GGUF/llama.cpp runtime | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| cmake \ | |
| git \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Set up a new user named "user" with UID 1000 (Hugging Face convention) | |
| RUN useradd -m -u 1000 user | |
| # Setup writeable cache directories under /tmp | |
| ENV HOME=/tmp \ | |
| HF_HOME=/tmp/huggingface_cache \ | |
| XDG_CACHE_HOME=/tmp/cache \ | |
| TORCH_EXTENSIONS_DIR=/tmp/torch_extensions \ | |
| TRITON_CACHE_DIR=/tmp/triton_cache \ | |
| PORT=7860 | |
| WORKDIR /code | |
| # Copy and install Python dependencies | |
| COPY requirements.txt /code/requirements.txt | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu | |
| RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | |
| # Copy code with ownership | |
| COPY --chown=user:user . /code | |
| # Set user to 1000 | |
| USER user | |
| EXPOSE 7860 | |
| # Run with single Uvicorn worker as per model API specifications | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"] | |