# Use an official Python runtime as a parent image FROM python:3.10-slim # Set environment variables to prevent interactive prompts during installation ENV DEBIAN_FRONTEND=noninteractive # Install system dependencies required by the application (only poppler) RUN apt-get update && apt-get install -y \ poppler-utils \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Create a non-root user for security RUN useradd --create-home --shell /bin/bash appuser # Set the working directory in the container WORKDIR /app # Copy the requirements file and install Python dependencies # This is done in a separate layer to leverage Docker's build cache COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application's code into the container COPY app.py . # Change ownership of the app directory to the non-root user RUN chown -R appuser:appuser /app # Switch to the non-root user USER appuser # Expose the port the Gradio app will run on EXPOSE 7860 # The command to run the Gradio application # Gradio's launch() method will automatically bind to 0.0.0.0 inside Docker. CMD ["python", "app.py"]