File size: 1,158 Bytes
f547e3d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 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"] |