# Use an official Python runtime as the base image | |
FROM python:3.9-slim | |
# Set up a non-root user | |
RUN useradd -m -u 1000 user | |
# Set the working directory in the container | |
WORKDIR /app | |
# Copy the requirements file into the container | |
COPY requirements.txt . | |
# Install the required packages | |
RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
# Copy the current directory contents into the container | |
COPY . . | |
# Create a directory for flagged data and set permissions | |
RUN mkdir /app/flagged && chown user:user /app/flagged | |
# Switch to the non-root user | |
USER user | |
# Make port 7860 available to the world outside this container | |
EXPOSE 7860 | |
# Set Python to ignore deprecation warnings | |
ENV PYTHONWARNINGS="ignore:on_event is deprecated:DeprecationWarning" | |
# Run the Gradio app when the container launches | |
CMD ["python", "app.py"] |