|
| 1 | + |
| 2 | +FROM debian:11 |
| 3 | + |
| 4 | +ENV LANG=C.UTF-8 \ |
| 5 | + LC_ALL=C.UTF-8 \ |
| 6 | + # ConTeXt cache can be created on runtime and does not need to |
| 7 | + # increase image size |
| 8 | + TEXLIVE_INSTALL_NO_CONTEXT_CACHE=1 \ |
| 9 | + # As we will not install regular documentation why would we want to |
| 10 | + # install perl docs… |
| 11 | + NOPERLDOC=1 |
| 12 | + |
| 13 | +COPY ./debian-cn-mirror.txt /etc/apt/sources.list |
| 14 | + |
| 15 | +RUN apt-get update && \ |
| 16 | + # basic utilities for TeX Live installation |
| 17 | + apt-get install -qy --no-install-recommends curl git unzip \ |
| 18 | + # miscellaneous dependencies for TeX Live tools |
| 19 | + make fontconfig perl default-jre libgetopt-long-descriptive-perl \ |
| 20 | + libdigest-perl-md5-perl libncurses5 libncurses6 \ |
| 21 | + # for latexindent (see #13) |
| 22 | + libunicode-linebreak-perl libfile-homedir-perl libyaml-tiny-perl \ |
| 23 | + # for eps conversion (see #14) |
| 24 | + ghostscript \ |
| 25 | + # for metafont (see #24) |
| 26 | + libsm6 \ |
| 27 | + # for syntax highlighting |
| 28 | + python3 python3-pygments \ |
| 29 | + # for gnuplot backend of pgfplots (see !13) |
| 30 | + gnuplot-nox \ |
| 31 | + equivs \ |
| 32 | + # at this point also install gpg and gpg-agent to allow tlmgr's |
| 33 | + # key subcommand to work correctly (see #21) |
| 34 | + gpg gpg-agent \ |
| 35 | + # we install using rsync so we need to have it installed |
| 36 | + rsync && \ |
| 37 | + rm -rf /var/lib/apt/lists/* && \ |
| 38 | + rm -rf /var/cache/apt/ && \ |
| 39 | + # bad fix for python handling |
| 40 | + ln -s /usr/bin/python3 /usr/bin/python |
| 41 | + |
| 42 | +# whether to install documentation and/or source files |
| 43 | +# this has to be yes or no |
| 44 | +ARG DOCFILES=no |
| 45 | +ARG SRCFILES=no |
| 46 | +ARG SCHEME=full |
| 47 | + |
| 48 | +# the mirror from which we will download TeX Live: in cn |
| 49 | +ARG TLMIRRORURL="rsync://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet/" |
| 50 | + |
| 51 | +# whether to create font and ConTeXt caches |
| 52 | +ARG GENERATE_CACHES=yes |
| 53 | + |
| 54 | +WORKDIR /tmp |
| 55 | + |
| 56 | +# download and install equivs file for dummy package |
| 57 | +RUN curl https://tug.org/texlive/files/debian-equivs-2022-ex.txt --output texlive-local && \ |
| 58 | + sed -i "s/2022/9999/" texlive-local && \ |
| 59 | + # freeglut3 does not ship with debian testing, so we remove it because there |
| 60 | + # is no GUI need in the container anyway (see #28) |
| 61 | + sed -i "/Depends: freeglut3/d" texlive-local && \ |
| 62 | + # apt-get update && \ |
| 63 | + # # Mark all texlive packages as installed. This enables installing |
| 64 | + # # latex-related packges in child images. |
| 65 | + # # Inspired by https://tex.stackexchange.com/a/95373/9075. |
| 66 | + # apt-get install -qy --no-install-recommends equivs \ |
| 67 | + # # at this point also install gpg and gpg-agent to allow tlmgr's |
| 68 | + # # key subcommand to work correctly (see #21) |
| 69 | + # gpg gpg-agent \ |
| 70 | + # # we install using rsync so we need to have it installed |
| 71 | + # rsync && \ |
| 72 | + # rm -rf /var/lib/apt/lists/* && \ |
| 73 | + # apt-get clean && \ |
| 74 | + # rm -rf /var/cache/apt/ |
| 75 | + # we need to change into tl-equis to get it working |
| 76 | + equivs-build texlive-local && \ |
| 77 | + dpkg -i texlive-local_9999.99999999-1_all.deb && \ |
| 78 | + apt-get install -qyf --no-install-recommends && \ |
| 79 | + # reverse the cd command from above and cleanup |
| 80 | + rm -rf ./*texlive* && \ |
| 81 | + # save some space |
| 82 | + apt-get remove -y --purge equivs && \ |
| 83 | + apt-get autoremove -qy --purge && \ |
| 84 | + rm -rf /var/lib/apt/lists/* && \ |
| 85 | + apt-get clean && \ |
| 86 | + rm -rf /var/cache/apt/ |
| 87 | + |
| 88 | +RUN echo "Fetching installation from mirror $TLMIRRORURL" && \ |
| 89 | + rsync -a --stats "$TLMIRRORURL" texlive && \ |
| 90 | + cd texlive && \ |
| 91 | + # create installation profile for full scheme installation with |
| 92 | + # the selected options |
| 93 | + echo "Building with documentation: $DOCFILES" && \ |
| 94 | + echo "Building with sources: $SRCFILES" && \ |
| 95 | + echo "Building with scheme: $SCHEME" && \ |
| 96 | + # choose complete installation |
| 97 | + echo "selected_scheme scheme-$SCHEME" > install.profile && \ |
| 98 | + # … but disable documentation and source files when asked to stay slim |
| 99 | + if [ "$DOCFILES" = "no" ]; then echo "tlpdbopt_install_docfiles 0" >> install.profile && \ |
| 100 | + echo "BUILD: Disabling documentation files"; fi && \ |
| 101 | + if [ "$SRCFILES" = "no" ]; then echo "tlpdbopt_install_srcfiles 0" >> install.profile && \ |
| 102 | + echo "BUILD: Disabling source files"; fi && \ |
| 103 | + echo "tlpdbopt_autobackup 0" >> install.profile && \ |
| 104 | + # furthermore we want our symlinks in the system binary folder to avoid |
| 105 | + # fiddling around with the PATH |
| 106 | + echo "tlpdbopt_sys_bin /usr/bin" >> install.profile && \ |
| 107 | + # actually install TeX Live |
| 108 | + ./install-tl -profile install.profile && \ |
| 109 | + cd .. && \ |
| 110 | + rm -rf texlive |
| 111 | + |
| 112 | +WORKDIR / |
| 113 | +RUN echo "Set PATH to $PATH" && \ |
| 114 | + $(find /usr/local/texlive -name tlmgr) path add && \ |
| 115 | + # Temporary fix for ConTeXt (#30) |
| 116 | + (sed -i '/package.loaded\["data-ini"\]/a if os.selfpath then environment.ownbin=lfs.symlinktarget(os.selfpath..io.fileseparator..os.selfname);environment.ownpath=environment.ownbin:match("^.*"..io.fileseparator) else environment.ownpath=kpse.new("luatex"):var_value("SELFAUTOLOC");environment.ownbin=environment.ownpath..io.fileseparator..(arg[-2] or arg[-1] or arg[0] or "luatex"):match("[^"..io.fileseparator.."]*$") end' /usr/bin/mtxrun.lua || true) && \ |
| 117 | + # pregenerate caches as per #3; overhead is < 5 MB which does not really |
| 118 | + # matter for images in the sizes of GBs; some TL schemes might not have |
| 119 | + # all the tools, therefore failure is allowed |
| 120 | + # make cn great |
| 121 | + tlmgr option repository https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet && \ |
| 122 | + if [ "$GENERATE_CACHES" = "yes" ]; then \ |
| 123 | + echo "Generating caches and ConTeXt files" && \ |
| 124 | + (luaotfload-tool -u || true) && \ |
| 125 | + # also generate fontconfig cache as per #18 which is approx. 20 MB but |
| 126 | + # benefits XeLaTeX user to load fonts from the TL tree by font name |
| 127 | + (cp "$(find /usr/local/texlive -name texlive-fontconfig.conf)" /etc/fonts/conf.d/09-texlive-fonts.conf || true) && \ |
| 128 | + fc-cache -fsv && \ |
| 129 | + if [ -f "/usr/bin/context" ]; then \ |
| 130 | + mtxrun --generate && \ |
| 131 | + texlua /usr/bin/mtxrun.lua --luatex --generate && \ |
| 132 | + context --make && \ |
| 133 | + context --luatex --make; \ |
| 134 | + fi \ |
| 135 | + else \ |
| 136 | + echo "Not generating caches or ConTeXt files"; \ |
| 137 | + fi |
| 138 | + |
| 139 | +RUN \ |
| 140 | + # test the installation; we only test the full installation because |
| 141 | + # in that, all tools are present and have to work |
| 142 | + if [ "$SCHEME" = "full" ]; then \ |
| 143 | + latex --version && printf '\n' && \ |
| 144 | + biber --version && printf '\n' && \ |
| 145 | + xindy --version && printf '\n' && \ |
| 146 | + arara --version && printf '\n' && \ |
| 147 | + context --version && printf '\n' && \ |
| 148 | + context --luatex --version && printf '\n' && \ |
| 149 | + if [ "$DOCFILES" = "yes" ]; then texdoc -l geometry; fi && \ |
| 150 | + if [ "$SRCFILES" = "yes" ]; then kpsewhich amsmath.dtx; fi; \ |
| 151 | + fi && \ |
| 152 | + python --version && printf '\n' && \ |
| 153 | + pygmentize -V && printf '\n' |
0 commit comments