Spaces:
Running
Running
| FROM python:3.10-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Set environment variables to prevent pyc files and buffer output | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 | |
| # Install system dependencies (if any are needed for specific python packages) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements from backend | |
| COPY backend/requirements.txt /app/requirements.txt | |
| # Install dependencies | |
| RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt | |
| # Copy the backend code | |
| COPY backend /app/backend | |
| # We do not copy the legacy main.py from root to enable clean separation | |
| # Create a non-root user (Hugging Face Spaces requirement) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Expose the port HF Spaces uses (7860) | |
| EXPOSE 7860 | |
| # Command to run the application | |
| # We use uvicorn to run the app found in backend.main:app | |
| CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"] |