FROM python:3.11-slim # Install system dependencies for Manim and general usage RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ ffmpeg \ libcairo2-dev \ libpango1.0-dev \ texlive \ texlive-latex-extra \ texlive-fonts-recommended \ dvisvgm \ pkg-config \ python3-dev \ sudo \ espeak-ng \ && rm -rf /var/lib/apt/lists/* # Create a non-root user (Hugging Face requirement) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # Copy requirements first to leverage Docker cache COPY --chown=user requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application COPY --chown=user . . # Make start script executable RUN chmod +x start.sh # Expose the port (Hugging Face Spaces uses 7860 by default) EXPOSE 7860 # Set environment variables ENV PYTHONUNBUFFERED=1 # Run the start script CMD ["./start.sh"]