manimate / Dockerfile
sourize
Updated Code
655bdb7
# Use Python 3.10 slim as base image
FROM python:3.10-slim
# Set working directory
WORKDIR /app
# Install system dependencies required for Manim
RUN apt-get update && apt-get install -y \
build-essential \
libcairo2-dev \
libpango1.0-dev \
ffmpeg \
libgirepository1.0-dev \
gir1.2-gtk-3.0 \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-bad1.0-dev \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
gstreamer1.0-tools \
gstreamer1.0-x \
gstreamer1.0-alsa \
gstreamer1.0-gl \
gstreamer1.0-gtk3 \
gstreamer1.0-qt5 \
gstreamer1.0-pulseaudio \
# LaTeX and Font dependencies
texlive-latex-base \
texlive-latex-extra \
texlive-fonts-extra \
texlive-latex-recommended \
texlive-science \
latexmk \
dvisvgm \
fontconfig \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Create necessary directories and set permissions
RUN mkdir -p /tmp/manimate/output \
&& mkdir -p /tmp/matplotlib \
&& mkdir -p /tmp/fontconfig \
&& chmod 777 /tmp/matplotlib \
&& chmod 777 /tmp/fontconfig \
&& fc-cache -f -v
# Set fontconfig environment variables
ENV FONTCONFIG_PATH=/etc/fonts
ENV FONTCONFIG_FILE=/etc/fonts/fonts.conf
ENV FONTCONFIG_CACHE=/tmp/fontconfig
# Copy requirements first to leverage Docker cache
COPY requirements.txt .
# Upgrade pip and install Python dependencies
RUN python -m pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir streamlit==1.28.0 && \
pip cache purge
# Copy the rest of the application
COPY . .
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app
ENV STREAMLIT_SERVER_PORT=8501
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
ENV STREAMLIT_SERVER_HEADLESS=true
ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
ENV MPLCONFIGDIR=/tmp/matplotlib
# Expose the port Streamlit runs on
EXPOSE 8501
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8501/_stcore/health || exit 1
# Command to run the application
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]