Skip to content

Conversation

@dor2727
Copy link
Contributor

@dor2727 dor2727 commented Oct 31, 2020

Added a Dockerfile

The Dockerfile has 4 different docker installation options:

  1. installing via pip
  2. installing via git clone
  3. installing via copying a local directory (which itself is a git clone)
  4. only installing dependencies, and manually (using -v) mounting a git repository

@leotrs
Copy link
Contributor

leotrs commented Oct 31, 2020

Hello @dor2727 and thank you for your contribution. Have you been able to take a look at our past conversations about docker? #13

Cc @PhilipEnchin

@dor2727
Copy link
Contributor Author

dor2727 commented Oct 31, 2020

Read it now, thanks!
I don't have plenty of spare time, but when I do, I'd be happy to help keep the dockerfile maintained.

BTW, maybe putting the Dockerfile in the scripts folder would make things simpler?
It won't clutter the main folder, while being available to those who want it.

@PhilipEnchin
Copy link
Contributor

@dor2727 - This is sweet. It's been on my to do list for a bit, but I'm delighted that someone's taken it on. (I'm very pro-docker...)

When I have a bit of time, I'd be interested in adding a docker-compose file too, which I can do unless that's something you're already planning on...

@leotrs
Copy link
Contributor

leotrs commented Nov 1, 2020

As stated in that discussion, I'm always happy to provide another way for users to get manim. However, the costs of maintaining the dockerfile will be large. As soon as this is published, users will expect it to always work. Nobody in the current dev team has capacity to commit to maintaining the docker file.

If you all are volunteering to maintain it, then by all means! However, this may imply a longer involvement than you had planned 😅

@naveen521kk
Copy link
Member

naveen521kk commented Nov 1, 2020

Maybe you can also contribute a small action to test the Dockerfile? That would help us maintaining it a lot.

Also, Thank you, for your contribution.

Dockerfile Outdated
Comment on lines 65 to 68
RUN python3 -m pip uninstall -y pangocairocffi cairocffi pangocffi
RUN pip3 install --no-binary :all: -U cairocffi --no-cache
RUN pip3 install --no-binary :all: -U pangocffi --no-cache
RUN pip3 install --no-binary :all: -U pangocairocffi --no-cache
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather suggest running --no-cache in pip3 install manimce itself and simple this can be ignored.

@dor2727
Copy link
Contributor Author

dor2727 commented Nov 1, 2020

@naveen521kk

also contribute a small action to test the Dockerfile

Great idea!
I did a small update to the entrypoint in the dockerfile, which now allows the following simple test:

docker run --rm -it manimce "python -m manim example_scenes/basic.py SquareToCircle --low_quality -s > /dev/null 2>&1 && echo yay || echo nay"

This will run an instance of this docker, execute python calling manim, render a simple scene, and echo 'yay' or 'nay', indicating if it all worked.

@naveen521kk
Copy link
Member

naveen521kk commented Nov 1, 2020

also contribute a small action to test the Dockerfile

What I was expecting was to Github Actions. Anyways this is also good. But again a Github Action is needed.

@leotrs
Copy link
Contributor

leotrs commented Nov 1, 2020

What would the GH action involve? Installing the dockerfile and reporting if it succeeds?

@naveen521kk
Copy link
Member

What would the GH action involve? Installing the dockerfile and reporting if it succeeds?

Yeah, and also runs tests there, something like an example_scene or pytest. It helps I find whether this is broken and would help a lot in maintaining.

@behackl
Copy link
Member

behackl commented Nov 2, 2020

Thank you for initiating this, I think we should definitely support docker and we have set some things in motion!

  • We have created a dockerhub organization, manimcommunity with a corresponding manim repository (https://hub.docker.com/u/manimcommunity/manim)
  • I optimized your image a little. My dockerfile for specifically our release v0.1.0 reads as
FROM python:3.7-slim

RUN apt-get update -q \
    && apt-get install --no-install-recommends -y \
        ffmpeg \
        gcc \
        git \
        libcairo2-dev \
        libffi-dev \
        libpango1.0-dev \
        pkg-config \
        wget

# setup a minimal texlive installation
COPY ./texlive-profile.txt /tmp/
ENV PATH=/usr/local/texlive/bin/x86_64-linux:$PATH
RUN wget -O /tmp/install-tl-unx.tar.gz http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz && \
    mkdir /tmp/install-tl && \
    tar -xzf /tmp/install-tl-unx.tar.gz -C /tmp/install-tl --strip-components=1 && \
    /tmp/install-tl/install-tl --profile=/tmp/texlive-profile.txt \
    && tlmgr install \
        amsmath babel-english cm-super doublestroke dvisvgm fundus-calligra \
        jknapltx latex-bin microtype ms physics preview ragged2e relsize rsfs \
        setspace standalone tipa wasy wasysym xcolor xkeyval

# clone and build manim
RUN git clone --depth 1 --branch v0.1.0 https://github.com/ManimCommunity/manim.git /opt/manim
WORKDIR /opt/manim
RUN pip install --no-cache .

# ensure ffi bindings are generated correctly
WORKDIR /usr/local/lib/python3.7/site-packages
RUN python cairocffi/ffi_build.py \
    && python pangocffi/ffi_build.py \
    && python pangocairocffi/ffi_build.py

WORKDIR /manim
RUN chmod 666 /manim

CMD [ "/bin/bash" ]

The main difference is that I try to keep a more minimal texlive installation, bringing the image down to approx. 1.27GB -- but I am sure there is more potential for optimization; I am very interested in hearing your opinions @dor2727 @PhilipEnchin. The tex packages are chosen in a way that make our test suite pass in the container (pip install pytest && cd /opt/manim && pytest).

Ideally, I'd like to have images corresponding to our releases and maybe additionally the status of our stable branch. (This would correspond to the available versions of our documentation. I am not sure about supporting a latest image corresponding to our (unstable) master branch as well.)

@naveen521kk
Copy link
Member

--profile=/tmp/texlive-profile.txt

Did you create a profile already? Because profile specifies what are things to be installed. Also, I would rather use TinyTeX as done in windows.

@behackl
Copy link
Member

behackl commented Nov 2, 2020

--profile=/tmp/texlive-profile.txt

Did you create a profile already? Because profile specifies what are things to be installed. Also, I would rather use TinyTeX as done in windows.

Yes, I've used the following simple texlive.profile:

selected_scheme scheme-minimal
TEXDIR /usr/local/texlive
TEXMFCONFIG ~/.texlive/texmf-config
TEXMFHOME ~/texmf
TEXMFLOCAL /usr/local/texlive/texmf-local
TEXMFSYSCONFIG /usr/local/texlive/texmf-config
TEXMFSYSVAR /usr/local/texlive/texmf-var
TEXMFVAR ~/.texlive/texmf-var
option_doc 0
option_src 0

I have a strong preference for staying with the current texlive installation. Besides, there does not seem to be too much of a difference between what tinytex does (it selects the scheme-infraonly scheme in texlive.profile, in contrast to the scheme-minimal used here).

I will probably open a fresh PR with this setup (sorry, @dor2727 for the "hostile takeover") later today.

@dor2727
Copy link
Contributor Author

dor2727 commented Nov 2, 2020

@behackl
That looks great! Thanks!
Personally, I don't install manim in the docker, but rather install the dependencies, and then mount the folder from the host, so that I'd be able to edit files with sublime (which is the 4th option in the dockerfile I made). But yours is better. There's no need to put my personal preferences in the main dockerfile.
And no problem :)
By the way, is there a reason not to use python3.8?

@dor2727
Copy link
Contributor Author

dor2727 commented Nov 2, 2020

WORKDIR /manim
RUN chmod 666 /manim

Maybe this should be changed to /opt/manim, since this is where manim is installed.

@behackl
Copy link
Member

behackl commented Nov 2, 2020

That looks great! Thanks!
Personally, I don't install manim in the docker, but rather install the dependencies, and then mount the folder from the host, so that I'd be able to edit files with sublime (which is the 4th option in the dockerfile I made). But yours is better. There's no need to put my personal preferences in the main dockerfile.

"Better" is definitely not correct: we are considering sort of different use cases. I'd like to provide an image for a fixed version of manim-community so that you can use it to compile given scenes with the version installed in the container. Your setup is way more flexible.

By the way, is there a reason not to use python3.8?

Ah, actually no: I noticed that python3.7 is a system dependency of the libcairo2-dev package and thought using the container for 3.7 would avoid installation of it -- but thats not true, it is installed anyways. We can gladly switch to 3.8.

@behackl
Copy link
Member

behackl commented Nov 2, 2020

WORKDIR /manim
RUN chmod 666 /manim

Maybe this should be changed to /opt/manim, since this is where manim is installed.

Hmm. I chose a separate, clean directory because I wanted to make mounting something into it as flexible as possible. If users were to mount their working directory to /opt/manim, the library would be hidden by the mount, meaning that users would still have to mount to, e.g., /manim -- and then, commands like

docker run --rm -it  --user="$(id -u):$(id -g)" -v "$(pwd)":/manim manimcommunity/manim manim test_scenes.py CircleToSquare -qm

would need to call /manim/test_scenes.py instead of just test_scenes.py. (It is also possible that the media dir is created in /opt/manim then, so the video is not simply placed in the mounted volume either.)

@dor2727
Copy link
Contributor Author

dor2727 commented Nov 2, 2020

I see. Overriding the mount is a great option.

And maybe we can create different docker tags.
e.g. manim:v0.1.0 would have your docker
and manim:latest would have my generic installation
or something like manim:latex-slim / manim:latex-full

@behackl
Copy link
Member

behackl commented Nov 6, 2020

As discussed above, this is superseded by #681.

@behackl behackl closed this Nov 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants