FROM python:3.8-slim # Create non-root user RUN useradd -m -u 1000 user # Set user home and working directory ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # Install system dependencies RUN apt-get update && apt-get install -y \ curl \ && rm -rf /var/lib/apt/lists/* # Copy requirements and install as root for pip COPY --chown=user:user requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy all application files COPY --chown=user:user . . # Switch to user USER user # Set Gradio environment variables ENV GRADIO_SERVER_NAME=0.0.0.0 \ GRADIO_SERVER_PORT=7860 # Expose port EXPOSE 7860 # Run the application CMD ["python", "app.py"]