Spaces:
Sleeping
Sleeping
| # Use a lightweight Python image | |
| FROM python:3.10-slim | |
| # Set working directory | |
| WORKDIR /code | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements and install | |
| COPY ./requirements.txt /code/requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | |
| # Create a non-root user (Hugging Face requirement) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Copy the rest of the app | |
| WORKDIR $HOME/app | |
| COPY --chown=user . $HOME/app | |
| # Ensure the transformers cache is in a writable directory | |
| ENV HF_HOME=/home/user/app/.cache | |
| RUN mkdir -p /home/user/app/.cache && chmod 777 /home/user/app/.cache | |
| # Expose port 7860 (Hugging Face default) | |
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"] |