# Dockerfile for ManimStudio - Hugging Face Spaces # Based on Python 3.11 slim with Manim dependencies FROM python:3.11-slim # Set working directory WORKDIR /app # Install system dependencies required by Manim # - ffmpeg: Video processing and conversion # - libcairo2-dev: 2D graphics rendering # - libpango1.0-dev: Text layout and rendering # - texlive packages: LaTeX for mathematical formulas RUN apt-get update && apt-get install -y \ ffmpeg \ libcairo2-dev \ libpango1.0-dev \ pkg-config \ texlive \ texlive-latex-extra \ texlive-fonts-extra \ texlive-latex-recommended \ texlive-science \ tipa \ libpq-dev \ gcc \ g++ \ && rm -rf /var/lib/apt/lists/* # Create non-root user (Hugging Face Spaces requirement) RUN useradd -m -u 1000 user # Switch to user USER user # Set environment variables ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ PYTHONUNBUFFERED=1 \ PYTHONIOENCODING=utf-8 # Set working directory for user WORKDIR $HOME/app # Copy requirements file COPY --chown=user:user requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir --user -r requirements.txt # Copy application files COPY --chown=user:user config.py . COPY --chown=user:user models.py . COPY --chown=user:user validators.py . COPY --chown=user:user renderer.py . COPY --chown=user:user converter.py . COPY --chown=user:user cleanup.py . COPY --chown=user:user mcp_integration.py . COPY --chown=user:user app.py . # Copy static resources (video player UI) COPY --chown=user:user static/ ./static/ # Create temporary render directory RUN mkdir -p /tmp/manim_renders # Expose port 7860 (Hugging Face Spaces standard) EXPOSE 7860 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD python -c "import httpx; httpx.get('http://localhost:7860/health', timeout=5)" # Run FastAPI application with uvicorn CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]