# Use a stable Python 3.11 base image FROM python:3.11-slim # Install system dependencies as root RUN apt-get update && apt-get install -y \ build-essential \ && rm -rf /var/lib/apt/lists/* # Set the working directory WORKDIR /app # Copy requirements first to leverage Docker cache COPY requirements.txt . # Install Python packages as root into the system path RUN pip install --no-cache-dir -r requirements.txt # Create a non-root user for security (HF requirement) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Copy the rest of the app files as the new user COPY --chown=user . . # Expose the mandatory Gradio port EXPOSE 7860 # Run the app CMD ["python", "app.py"]