Spaces:
Running
Running
| # Use a slim Python image for a smaller footprint | |
| FROM python:3.11-slim | |
| # Set the working directory | |
| WORKDIR /app | |
| # Create a non-root user for Hugging Face security | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| # Copy requirements first to leverage Docker cache | |
| # Use --chown=user:user to ensure the new user owns the files | |
| COPY --chown=user:user requirements.txt . | |
| # Install dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the rest of the application code | |
| COPY --chown=user:user . . | |
| # Hugging Face Spaces listens on port 7860 by default | |
| EXPOSE 7860 | |
| # Start the FastAPI app using uvicorn | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |