# Base Image: Lightweight Python 3.10 FROM python:3.10-slim # Set working directory WORKDIR /app # Copy requirements and install dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Create a non-root user (Mandatory for security in Hugging Face Spaces) RUN useradd -m -u 1000 user USER user # Set environment variables for the non-root user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Change working directory to the user's home WORKDIR $HOME/app # Copy the rest of the application code with proper ownership COPY --chown=user . $HOME/app # Expose the standard Hugging Face port EXPOSE 7860 # Run the Flask application # (Using python directly since we are relying on Flask's internal server for background threads) CMD ["python", "app.py"]