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

Projects
None yet
4 participants
@tkw1536
Contributor

tkw1536 commented Jun 19, 2018

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

@dginev

This comment has been minimized.

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

This comment has been minimized.

Contributor

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 tkw1536 force-pushed the tkw1536:with-dockerfile branch from 00fac7f to 2387d7c Jun 20, 2018

@tkw1536

This comment has been minimized.

Contributor

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

This comment has been minimized.

@dginev

dginev Jun 20, 2018

Collaborator

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 .

This comment has been minimized.

@dginev

dginev Jun 20, 2018

Collaborator

this last line is very cool to read!

@brucemiller

This comment has been minimized.

Owner

brucemiller commented Jun 21, 2018

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 tkw1536 force-pushed the tkw1536:with-dockerfile branch from 2387d7c to 938c62f Jun 21, 2018

@tkw1536

This comment has been minimized.

Contributor

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

This comment has been minimized.

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.

@tkw1536 tkw1536 force-pushed the tkw1536:with-dockerfile branch from 938c62f to eb4df00 Jun 21, 2018

Add Dockerfile
This commit adds a Dockerfile, which can be used to run latexml inside
a Docker Container.

@tkw1536 tkw1536 force-pushed the tkw1536:with-dockerfile branch from eb4df00 to 65a15ce Jun 21, 2018

@tkw1536

This comment has been minimized.

Contributor

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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.

Optionally add texlive to Dockerfile
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

This comment has been minimized.

Contributor

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.

@tkw1536 tkw1536 force-pushed the tkw1536:with-dockerfile branch from e4cbcce to d5b48fb Jun 26, 2018

@brucemiller brucemiller merged commit fb71c30 into brucemiller:master Jun 26, 2018

1 check was pending

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details

@tkw1536 tkw1536 deleted the tkw1536:with-dockerfile branch Jun 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment