| FROM pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel | |
| USER root | |
| RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| WORKDIR /app | |
| # Upgrade pip and install unsloth properly | |
| RUN pip install --no-cache-dir --upgrade pip | |
| RUN pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git" | |
| COPY --chown=user ./requirements.txt requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy all the code | |
| COPY --chown=user . /app | |
| # Ensure correct permissions for checkpoint saving | |
| USER root | |
| RUN chown -R user:user /app | |
| USER user | |
| # Hugging Face spaces expect the app to run on 7860 | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |