# Use the official Python image as a base image FROM python:3.9-slim # Set the working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ libgl1-mesa-glx \ libglib2.0-0 \ gcc \ g++ \ python3-tk \ tk-dev \ ffmpeg \ fonts-liberation \ && rm -rf /var/lib/apt/lists/* # Copy project files to the container COPY . /app # Upgrade pip RUN pip install --upgrade pip # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Set environment variables ENV PYTHONUNBUFFERED=1 ENV LANG=C.UTF-8 ENV LC_ALL=C.UTF-8 ENV MPLCONFIGDIR=/tmp/matplotlib # Create necessary directories and set permissions RUN mkdir -p /.fonts /.config /app/models && \ chmod -R 777 /.fonts /.config /app/models RUN mkdir -p /app/flagged && chmod 777 /app/flagged RUN apt-get update && apt-get install -y curl && \ curl -L -o /tmp/frpc_linux_amd64 https://cdn-media.huggingface.co/frpc-gradio-0.2/frpc_linux_amd64 && \ mv /tmp/frpc_linux_amd64 /usr/local/lib/python3.9/site-packages/gradio/frpc_linux_amd64_v0.2 # Create a non-root user RUN useradd -m appuser USER appuser # Run the application CMD ["python", "app.py"]