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

Using docker for building documents #302

Closed
lippertmarkus opened this issue Nov 10, 2017 · 10 comments
Closed

Using docker for building documents #302

lippertmarkus opened this issue Nov 10, 2017 · 10 comments
Labels
enhancement Issue suggests an enhancement

Comments

@lippertmarkus
Copy link

lippertmarkus commented Nov 10, 2017

No issue here. I just wanted to share my solution for using a docker container for building (maybe also an alternative to #119 ). This is especially useful if you for example don't want to install the huge texlive package on your computer. Another side effect is that on Windows the build process within a linux container is faster than building on the local system.

I just wrote myself a little script latexdocker.cmd for running the container. It should work for both Linux and Windows and just executes all arguments inside the container:

:; echo "Running on *nix";  docker run -i --rm -w /data -v "$(pwd):/data" tianon/latex $*; exit $?
@ECHO OFF
ECHO Running on Windows
docker run -i --rm -w /data -v "%cd%:/data" tianon/latex %*

I am using the tianon/latex image here, which is debian:jessie with texlive-full, biber, latexmk and make (Dockerfile). Compressed image is only 1GB!

In the settings of LaTex-Workshop you can just use the script and pass the binary and other arguments to it:

"latex-workshop.latex.toolchain": [
        {
            "command": "latexdocker.cmd",
            "args": [
                "latexmk",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "%DOCFILE%"
            ]
        }
]

Of course you can also use the other binaries like pdflatex and so on. Note that you can't use the %DOC% variable in the settings as it contains the path on the local machine instead of the one in the container.

@lippertmarkus lippertmarkus changed the title Using docker for building Using docker for building documents Nov 10, 2017
@James-Yu
Copy link
Owner

Thanks a lot for the description. Do you mind my incorporating the content into readme with credits?

@lippertmarkus
Copy link
Author

@James-Yu Go ahead! :) As I currently don't have the option: maybe someone should test if the latexdocker.cmd script is also working on Mac and Linux machines.

@tam3r
Copy link

tam3r commented Nov 26, 2017

Tried your script on a Mac.

That does not work:
:; echo "Running on *nix"; docker run -i --rm -w /data -v "$(pwd):/data" tianon/latex "$*"; exit $?

That works:
:; echo "Running on *nix"; docker run -i --rm -w /data -v "$(pwd):/data" tianon/latex $*; exit $?

@lippertmarkus
Copy link
Author

@tam3r Thanks for testing, I edited the script in #302 (comment)

@lippertmarkus
Copy link
Author

With newest edge build for Docker on Windows you can run LCOW aside of Windows containers. This requires to specify --platform linux when running linux containers in Windows-Container mode. The script should then look like:

:; echo "Running on *nix";  docker run -i --rm -w /data -v "$(pwd):/data" tianon/latex "$*"; exit $?
@ECHO OFF
ECHO Running on Windows
docker run --platform linux -i --rm -w /data -v "%cd%:/data" tianon/latex %*

@koppor
Copy link

koppor commented Mar 28, 2018

Note that tianon/latex uses texlive from Debian, which is a bit outdated. Currently, in debian/strech, it is texlive 2016. Currently, texlive 2017 is frozen and texlive 2018 is short before a release.

This might be not bad in general, but in case you a) want to have new packages (such as support for plantuml) or b) get the latest package updates, a newer version is beneficial.

In my image koppor/texlive, I am using TeX Live 2017 with the latest package updates and working setups for additional packages such as minted.

@shinokada
Copy link

shinokada commented Oct 13, 2020

@koppor
I added "latex-workshop.docker.image.latex":"koppor/texlive" to setings.json, but it didn't work on my Mac.

{
   ...
   // latex
    "latex-workshop.docker.enabled": true,
    "latex-workshop.latex.outDir": "./out",
    "latex-workshop.synctex.afterBuild.enabled": true,
    "latex-workshop.view.pdf.viewer": "tab",
    "latex-workshop.docker.image.latex":"koppor/texlive",
    // End
   ...
}

@koppor
Copy link

koppor commented Oct 13, 2020

Please try with danteev/texlive ( https://github.com/dante-ev/docker-texlive )

Yes, I should take down the Docker repository. The homepage redirects to the DANTE e.V. page, doesn't it?

@shinokada
Copy link

@koppor Thanks. It works but it shows "Formatting failed. Please refer to LaTeX Workshop Output for details."

@koppor
Copy link

koppor commented Oct 13, 2020

Is there some possibility that you can check the "LaTeX Workshop Output" for details?

Repository owner locked as resolved and limited conversation to collaborators Jun 19, 2021
@tamuratak tamuratak added the enhancement Issue suggests an enhancement label Jun 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Issue suggests an enhancement
Projects
None yet
Development

No branches or pull requests

6 participants