# Use official Python base image FROM python:3.11-slim # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ libfaiss-dev \ && rm -rf /var/lib/apt/lists/* # Create a non-root user (Required by HF Spaces) RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" # Copy requirements and install COPY --chown=user requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy the application code COPY --chown=user . . # Set environment variables ENV PYTHONUNBUFFERED=1 ENV PYTHONPATH=/app # HF Spaces expects port 7860 ENV PORT=7860 # Online Mode allowed for Spaces (to download model) ENV FORCE_OFFLINE=0 # Expose the port EXPOSE 7860 # Run the server CMD ["gunicorn", "--workers=1", "--threads=4", "--timeout=300", "--bind=0.0.0.0:7860", "src.app.server:app"]