FROM python:3.11-slim # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ curl \ git \ && rm -rf /var/lib/apt/lists/* # Create non-root user (required by HF Spaces) RUN useradd -m -u 1000 user WORKDIR /app # Copy and install requirements as root (system-wide) COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the entire application COPY . . # Make the app directory writable by user (for SQLite DB, logs, JSON files) RUN chown -R user:user /app # Switch to non-root user USER user ENV HOME=/home/user \ PATH="/home/user/.local/bin:$PATH" \ PYTHONUNBUFFERED=1 # Expose the port Hugging Face expects EXPOSE 7860 # Run the orchestration script CMD ["python", "main.py"]