FROM python:3.10-slim # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/* # Create user with UID 1000 RUN useradd -m -u 1000 user # Set environment variables ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PORT=7860 \ HOME=/home/user WORKDIR $HOME/app # Copy requirements and install COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application files COPY --chown=user . . # Switch to the non-root user USER user # Expose the HF Space port EXPOSE 7860 # Run the application CMD ["python", "main.py"]