Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile for use with Docker #1008

Merged
merged 3 commits into from Jun 26, 2018

Conversation

tkw1536
Copy link
Contributor

@tkw1536 tkw1536 commented Jun 19, 2018

This commit adds a Dockerfile to LaTeXML to be able to use latexml easily within a Docker container.

@dginev
Copy link
Collaborator

dginev commented Jun 20, 2018

Does this need to be separately maintained every time the Makefile.PL dependencies change? Why not use cpanm . instead, which will dynamically ensure all Perl dependencies are installed, based on Makefile.PL?

@tkw1536
Copy link
Contributor Author

tkw1536 commented Jun 20, 2018

That sounds like a good idea, I will update to use cpanm. Although this will need maintenance when the system dependencies (e.g. libxml etc) change.

@tkw1536
Copy link
Contributor Author

tkw1536 commented Jun 20, 2018

Alright, I have updated the PR.

Dockerfile Outdated
zlib-dev

# Install cpanmnius
RUN curl -L https://cpanmin.us | perl - App::cpanminus
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as in the other PR, you could add the cpanminus dependency to the apk section, instead of installing from curl, then it feels a bit more robust for a deployment setup.

Dockerfile Outdated

# Installing via cpanm
WORKDIR /opt/latexml
RUN cpanm .
Copy link
Collaborator

Choose a reason for hiding this comment

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

this last line is very cool to read!

@brucemiller
Copy link
Owner

One question: Is this file in the top-level LaTeXML directory? If so, is it needed to be there?
FWIW, I have a subdirectory "release", where I've parked whatever special build files I've collected (rpm specfile, macports Portfile, ...), so maybe that's a better place, to reduce top-level clutter?

@tkw1536
Copy link
Contributor Author

tkw1536 commented Jun 21, 2018

@dginev I have updated to use cpanm from official sources, thanks for the suggestion

@brucemiller The Dockerfile adds several files from the LaTeXML source code into the Docker Image. For this is it needs a directory (in Docker Terminology called a "build context") to take those files from.
It is not possible to add files from outside the build context.

By convention, the build context is the directory the Dockerfile resides in. This means if the Dockerfile moved to a subdirectory, the resulting docker image can only contain files in that directory.
It is still possible to build the Dockerfile with a different build context, but it would be highly unusual,

@dginev
Copy link
Collaborator

dginev commented Jun 21, 2018

For the sake of argument, would you ever have latexml dockerized on its own, without a web server or similar deployment that hosts it? Since you could always make the dockerizable aspects a plugin to the LaTeXML project. Now that I've merged the Dockerfile PR for LaTeXML::Plugin::ltxmojo, you could argue that suffices for practical purposes?

I suspect Bruce doesn't want random files parasitizing the Perl library repository.

This commit adds a Dockerfile, which can be used to run latexml inside
a Docker Container.
@tkw1536
Copy link
Contributor Author

tkw1536 commented Jun 21, 2018

I have moved the Dockerfile to the release sub-directory and added instructions on how to build it at the top of the file.

@bfirsh
Copy link
Contributor

bfirsh commented Jun 22, 2018

Dockerfile looks good to me. One extra thing we have in the Engrafo Dockerfile is installing all of Texlive. I forget what breaks now if you don't have that installed, but stuff did break for us. --includestyles styles obviously won't work.

Texlive is enormous though, so perhaps we could add that as another version of the image. Dockerfile.texlive or something. :)

@dginev Yes, it would be useful to use standalone. For example, this one-liner would allow you to convert documents without having to install anything on your machine:

$ docker run -v "$(pwd)":/workdir -w /workdir brucemiller/latexml latexmlc example.tex

I don't have that strong feelings about it, but things in Docker-land tend to work better if the Dockerfile is in the root of the directory. It's also a neat little advert to people reading the code that "hey - you can run this in Docker!"

Once the Dockerfile is in, an automated build could be set up on Docker Hub so the Docker image gets build on every commit. Then, docker run brucemiller/latexml will work. I'm happy to help if you want to set this up.

@dginev
Copy link
Collaborator

dginev commented Jun 22, 2018

Thanks for chiming in @bfirsh ! Now that you added that one-liner, you've reminded me we should also update the respective manual pages if we decide to include the docker file -- after all the latexml users should have examples and guidance. And the PR looks twice as legitimate a need now cc @brucemiller

@dginev
Copy link
Collaborator

dginev commented Jun 22, 2018

As to texlive, I think I remember @tkw1536 was telling me the other day that he wanted to add that as a flag to the command and make it configurable? Definitely helpful to have the choice.

This commit allows to specifiy a build argument `WITH_TEXLIVE` to
include TeXLive when building the Dockerfile. By default, this is set to
false.
@tkw1536
Copy link
Contributor Author

tkw1536 commented Jun 23, 2018

I have updated the Dockerfile to allow to optionally include TeXLive using build arguments. This works as following.

By default, no TeXLive is included. One would build the Docker Image like so:

docker build -t latexml -f release/Dockerfile .

To include TeXLive, the WITH_TEXLIVE build argument can be set to yes:

docker build -t latexml --build-arg WITH_TEXLIVE=yes -f release/Dockerfile .

In my tests, the docker image without TeXLIve is 215 MB in size, whereas the image with TeXLive is 2.81 GB in size.

Sadly DockerHub (for automated builds that @bfirsh suggested above) does not seem to support build arguments, so it is non-trivial to automate builds for both variants of the image.

@brucemiller brucemiller merged commit fb71c30 into brucemiller:master Jun 26, 2018
@tkw1536 tkw1536 deleted the with-dockerfile branch June 28, 2018 16:46
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.

None yet

4 participants