1

I am trying to create a Docker image with texlive which is not >4G heavy like docker.io/texlive/texlive. Installing e.g. from Debian sources won't build, because once you want to add certain packages (e.g. tlmgr install cleveref) right now it only says:

tlmgr: Local TeX Live (2020) is older than remote repository (2021).

because CTAN mirrors have updated to 2021, but Debian has not.

So I am trying to install the recommended way using install-tl-unx.tar.gz, but this also keeps failing because no CTAN mirror can be reached. Here is a minimum example of the Dockerfile:

FROM alpine:latest
RUN apk add perl
RUN wget https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz; \
    tar -xzf install-tl-unx.tar.gz;
RUN cd install-tl-* ; \
    perl ./install-tl 

It fails stating that it cannot contact mirror.ctan.org, even though a second before it downloaded the installer from the very same site:

query_ctan_mirror: Programs not set up, trying wget
Loading http://www.ctan.org/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb
cannot contact mirror.ctan.org, returning a backbone server!

./install-tl: TLPDB::from_file could not initialize from: http://www.ctan.org/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb ./install-tl: Maybe the repository setting should be changed. ./install-tl: More info: https://tug.org/texlive/acquire.html

We can even force using that server and also force HTTPS with the --location argument:

RUN cd install-tl-*; \
    perl ./install-tl --location https://mirror.ctan.org/systems/texlive/tlnet

Still the same, the server cannot be reached. I also tried other mirrors, which I tested to be available in my browser, none worked.

So I wonder what I need to do to have that installation run reliably, so that this can run inside a CI job.

MS-SPO
  • 11,519
mcnesium
  • 203
  • Perhaps not directly important, but why are you doing perl ./install.sh rather than just source ./install.sh? – Joseph Wright Apr 29 '21 at 15:08
  • 1
    Other than the above comment, what you are doing looks very similar to e.g. https://github.com/latex3/latex3/blob/main/support/texlive.sh – Joseph Wright Apr 29 '21 at 15:09
  • It says to use perl in the docs – mcnesium Apr 29 '21 at 15:09
  • That latex3 script is doing the same as mine. Downloading the installer works fine, but then the actual loading of texlive.tlpdb fails, see https://pastebin.com/a3viMFUX – mcnesium Apr 29 '21 at 15:22
  • This one seems important: cannot contact mirror.ctan.org, returning a backbone server!, is the docker build process behind some sort of proxy or similar. Note that when playing with this you can easily make your own copy of tlnet via the mirror nodes that supports rsync and then ask the installer to explicit use that until you know docker can build this thing. – daleif Apr 29 '21 at 15:37
  • The Docker build process is on my laptop. Also, as stated before, the server is reachable, because downloading the installer works fine. This can also run in one line, see here: https://gitlab.com/mcnesium/ctan-test/-/jobs/1223945497 – mcnesium Apr 29 '21 at 16:01
  • Since you didn't mention it: did you try running the installer script outside of the docker process to see if works? If I try to curl the URL that is listed in your question, I get an HTTP 302 redirect, but the link included in the redirect message points to an empty file when I tried to fetch it. – Willie Wong Apr 29 '21 at 16:30
  • Something else that is strange with your log: the line "cannot contact mirror..." is only output after the command query_ctan_mirror() failed, and so install_tl defaults to using the backbone. Therefore it should be printed before any attempt to load a tlpdb file. In any case, have you tried specifying a specific repository? Use for example --location https://ctan.math.washington.edu/tex-archive/systems/texlive/tlnet/? I am wondering if something in your system is chocking on the mirror redirects. – Willie Wong Apr 29 '21 at 17:25
  • Debian has a number of repository packages with smaller subsets of LaTeX packages, for example cleveref can be found in texlive-latex-extra (52MB). If you know which packages you want for your Docker image then you can probably find a suitable combination of Debian packages that is less than 4GB combined. – Marijn Apr 29 '21 at 18:27
  • Have a look at https://tex.stackexchange.com/a/466051 which is just about creating a minimal TL image. Below 1.7 GB is hard for fully functional. In the linked post, you might remove JDK etc. if you don't need the tools that need them. Also note that certain tools won't work on alpine (e.g. biber). – TeXnician Apr 30 '21 at 05:51
  • You mention that you don't like the texlive/texlive image but maybe the Dockerfile might help nevertheless. After all, the build succeeds and the basic instructions are very similar to yours. – TeXnician Apr 30 '21 at 05:53
  • @WillieWong yes I did try to run the installer on my host system, and it found the connection there. I even found out then that there is a prompt in the install, that asks to enter stuff, which can only be omitted by passing a profile file. This means, my minimal example above would fail anyway. Besides that, the URL above redirects (randomly?) to other sites, check it out: curl --head --silent --location --output /dev/null --write-out %{url_effective} http://www.ctan.org/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb – mcnesium Apr 30 '21 at 14:52
  • @WillieWong also yes I did try to use --location … with other mirrors, as I stated above. None worked, unfortunately – mcnesium Apr 30 '21 at 14:52
  • @Marijn Debian is the original reason why I am trying to build this using the installer. Debian still has TexLive 2020 in their repos. Installing them and then trying to install packages with tlmgr afterwards will fail with the "older than remote repository" error that I quoted above. – mcnesium Apr 30 '21 at 14:53
  • @TeXnician Since actually I want to use pandoc to build documents, I ended up using pandoc/latex image plus the tlmgr packages I need. This results in a 730MB image which is probably as low as I can go. It still installs more than I actually need, but at least not gigabytes of it. – mcnesium Apr 30 '21 at 14:53
  • I'm afraid this is probably a docker problem not a TeX problem... you may want to ask in a different forum. – Willie Wong Apr 30 '21 at 15:04
  • For your needs, perhaps you want to start from TinyTeX which is a stripped-down TeXlive installation geared to very much your use case. https://yihui.org/tinytex/ – Don Hosek Apr 30 '21 at 15:07
  • 1
    @mcnesium I understand the problem with tlmgr, the solution I proposed is to not use tlmgr for anything, but instead install a few small texlive-xyz packages from Debian, which would leave you with a 2020 TeX Live but that is fine for most purposes and is much less than 4GB - and most importantly it is very easy to install in Docker. In this scenario, if you want an extra package, you locate the appropriate Debian package that contains that LaTeX package, and you install that with apt or similar. – Marijn Apr 30 '21 at 15:12

1 Answers1

0

For those who search for a way to install texlive from CTAN in a Docker container based on Alpine, check out this repository kjarosh/latex-docker.

The repo contains a Dockerfile that installs texlive in one of the desired schemes - minimal (~40MB), basic (~90MB), small (~180MB), medium (~500MB), full (~2GB). Already with basic scheme I was able to use pdflatex command to compile .tex source into a .pdf file.

To install additional packages use tlmgr install <packagename> or even install a list of packages from a text file by running tlmgr install `cat texpackages.txt`. Note the backquotes are important otherwise the command won't work.

Paloha
  • 153