Spaces:
Sleeping
Sleeping
| FROM nvidia/cuda:12.5.1-cudnn-devel-ubuntu22.04 | |
| ENV DEBIAN_FRONTEND=noninteractive \ | |
| TZ=Europe/Paris | |
| # Remove any third-party apt sources to avoid issues with expiring keys. | |
| # Install some basic utilities | |
| RUN rm -f /etc/apt/sources.list.d/*.list && \ | |
| apt-get update && apt-get install -y --no-install-recommends \ | |
| curl \ | |
| ca-certificates \ | |
| sudo \ | |
| git \ | |
| wget \ | |
| procps \ | |
| git-lfs \ | |
| zip \ | |
| unzip \ | |
| htop \ | |
| vim \ | |
| nano \ | |
| bzip2 \ | |
| libx11-6 \ | |
| build-essential \ | |
| libsndfile-dev \ | |
| software-properties-common \ | |
| pkg-config \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install LaTeX (Full) - this should include dvisvgm | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| texlive-full \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install nvtop (available in Ubuntu 22.04 default repos) | |
| RUN apt-get update && \ | |
| apt-get install -y --no-install-recommends nvtop && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Install Node.js LTS | |
| RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \ | |
| apt-get install -y nodejs && \ | |
| npm install -g configurable-http-proxy | |
| # Create a working directory | |
| WORKDIR /app | |
| # Create a non-root user and switch to it | |
| RUN adduser --disabled-password --gecos '' --shell /bin/bash user \ | |
| && chown -R user:user /app | |
| RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user | |
| USER user | |
| # All users can use /home/user as their home directory | |
| ENV HOME=/home/user | |
| RUN mkdir $HOME/.cache $HOME/.config \ | |
| && chmod -R 777 $HOME | |
| # Set up the Conda environment with latest Miniconda | |
| ENV CONDA_AUTO_UPDATE_CONDA=false \ | |
| PATH=$HOME/miniconda/bin:$PATH | |
| RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \ | |
| && chmod +x ~/miniconda.sh \ | |
| && ~/miniconda.sh -b -p ~/miniconda \ | |
| && rm ~/miniconda.sh \ | |
| && conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main \ | |
| && conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r \ | |
| && conda clean -ya | |
| # Create a Python 3.11 environment for better compatibility | |
| RUN conda create -n manim python=3.11 -y && \ | |
| conda clean -ya | |
| # Activate the environment by default | |
| ENV CONDA_DEFAULT_ENV=manim | |
| ENV PATH=$HOME/miniconda/envs/manim/bin:$PATH | |
| WORKDIR $HOME/app | |
| ####################################### | |
| # Start root user section | |
| ####################################### | |
| USER root | |
| # User Debian packages | |
| ## Security warning : Potential user code executed as root (build time) | |
| RUN --mount=target=/root/packages.txt,source=packages.txt \ | |
| apt-get update && \ | |
| xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \ | |
| && rm -rf /var/lib/apt/lists/* | |
| RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \ | |
| bash /root/on_startup.sh | |
| RUN mkdir /data && chown user:user /data | |
| ####################################### | |
| # Install Manim dependencies (root) | |
| ####################################### | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| # Cairo and Pango for rendering | |
| libcairo2-dev \ | |
| libpango1.0-dev \ | |
| # FFmpeg for video processing | |
| ffmpeg \ | |
| # LaTeX for mathematical typesetting | |
| texlive \ | |
| texlive-latex-extra \ | |
| texlive-fonts-extra \ | |
| texlive-latex-recommended \ | |
| texlive-science \ | |
| texlive-fonts-recommended \ | |
| # Additional LaTeX packages for better compatibility | |
| texlive-xetex \ | |
| texlive-luatex \ | |
| # CRITICAL: Add dvisvgm explicitly | |
| dvisvgm \ | |
| # Font packages | |
| fonts-lmodern \ | |
| fonts-texgyre \ | |
| # TIPA for phonetic symbols | |
| tipa \ | |
| # Additional system dependencies | |
| libffi-dev \ | |
| libssl-dev \ | |
| zlib1g-dev \ | |
| libbz2-dev \ | |
| libreadline-dev \ | |
| libsqlite3-dev \ | |
| llvm \ | |
| libncurses5-dev \ | |
| libncursesw5-dev \ | |
| xz-utils \ | |
| tk-dev \ | |
| libxml2-dev \ | |
| libxmlsec1-dev \ | |
| libffi-dev \ | |
| liblzma-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Verify dvisvgm installation | |
| RUN which dvisvgm && dvisvgm --version | |
| ####################################### | |
| # End root user section | |
| ####################################### | |
| USER user | |
| # Ensure we're using the manim conda environment | |
| RUN echo "conda activate manim" >> ~/.bashrc | |
| RUN conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main | |
| RUN conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r | |
| # Install Python packages in the manim environment | |
| RUN --mount=target=requirements.txt,source=requirements.txt \ | |
| /home/user/miniconda/envs/manim/bin/pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Install Manim and IPython with specific versions for compatibility | |
| RUN /home/user/miniconda/envs/manim/bin/pip install --no-cache-dir \ | |
| manim[jupyterlab] \ | |
| IPython \ | |
| jupyter \ | |
| jupyterlab \ | |
| notebook \ | |
| # Additional dependencies that might be missing | |
| pillow \ | |
| numpy \ | |
| scipy \ | |
| matplotlib \ | |
| moderngl \ | |
| moderngl-window \ | |
| mapbox-earcut \ | |
| colour \ | |
| rich \ | |
| click \ | |
| click-default-group \ | |
| cloup \ | |
| decorator \ | |
| importlib-metadata \ | |
| isosurfaces \ | |
| manimpango \ | |
| markdown-it-py \ | |
| mdurl \ | |
| multipledispatch \ | |
| networkx \ | |
| pygments \ | |
| pydub \ | |
| requests \ | |
| screeninfo \ | |
| jupyter-collaboration \ | |
| skia-python \ | |
| srt \ | |
| tqdm \ | |
| watchdog | |
| # Copy the current directory contents into the container at $HOME/app setting the owner to the user | |
| COPY --chown=user . $HOME/app | |
| RUN chmod +x start_server.sh | |
| # Copy login template if it exists | |
| COPY --chown=user login.html /home/user/miniconda/envs/manim/lib/python3.11/site-packages/jupyter_server/templates/login.html | |
| # Set environment variables for better compatibility | |
| ENV PYTHONUNBUFFERED=1 \ | |
| GRADIO_ALLOW_FLAGGING=never \ | |
| GRADIO_NUM_PORTS=1 \ | |
| GRADIO_SERVER_NAME=0.0.0.0 \ | |
| GRADIO_THEME=huggingface \ | |
| SYSTEM=spaces \ | |
| SHELL=/bin/bash \ | |
| # Manim specific environment variables | |
| MANIMGL_LOG_LEVEL=INFO \ | |
| # Force software rendering if GPU issues occur | |
| MANIM_RENDERER=cairo | |
| CMD ["./start_server.sh"] |