我尝试过的方法

我尝试过的方法

我想制作一个最小化安装的docker镜像pdlatexxelatex我希望能够手动安装我需要的软件包(例如fontawesome

因为我想尽量简化,所以我想使用 Alpine,而不是 Ubuntu。但是对于大多数安装方法,它似乎tlmgr无法安装或不起作用。

我尝试过的方法

  1. natlownes 图像:基于 Ubuntu,因此太大(2GB)
  2. 布朗图像构建失败。基于 Ubuntu,所以无论如何也会很大。
  3. 我自己的 dockerfile,使用apk add(distro repo)
FROM alpine

RUN apk add --no-cache \
        texlive \
        texlive-xetex \
        texmf-dist \
        texmf-dist-formatsextra \
        texmf-dist-latexextra \
        texmf-dist-pictures \
        texmf-dist-science
RUN tlmgr install fontawesome

失败

Can't locate TeXLive/TLPDB.pm in @INC (you may need to install the TeXLive::TLPDB module) (@INC contains: /usr/share/texmf-dist/scripts/texlive /usr/share/tlpkg /usr/local/lib/perl5/site_perl /usr/local/share/perl5/site_perl /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl) at /usr/bin/tlmgr line 99.
BEGIN failed--compilation aborted at /usr/bin/tlmgr line 99.
  1. 我自己的 dockerfile,使用网络安装
sudo docker run -it --rm alpine sh
apk add --no-cache perl
wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tar -xzf install-tl-unx.tar.gz
cd install-tl-unx
./install-tl

输出:

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

./install-tl: TLPDB::from_file could not download http://www.ctan.org/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb;
./install-tl: maybe the repository setting should be changed.

有趣的是,我只需wget http://www.ctan.org/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb,就可以了。但我不知道在所有大型安装脚本中我需要查找哪里才能跳过该部分。

概括

我怎样才能使选项 3 或 4 发挥作用?

预期结果:pdflatexxelatex安装fontawesome在 Alpine Linux 上。

答案1

事实证明,与最小 LaTeX 安装的大小相比,Ubuntu 和 Alpine 之间的大小差异很小。

所以我刚刚安装了TinyTex在 Ubuntu 上。

FROM ubuntu:bionic

WORKDIR /var/local

# combine into one run command to reduce image size
RUN apt-get update && apt-get install -y perl wget libfontconfig1 && \
    wget -qO- "https://yihui.name/gh/tinytex/tools/install-unx.sh" | sh  && \
    apt-get clean
ENV PATH="${PATH}:/root/bin"
RUN tlmgr install xetex
RUN fmtutil-sys --all

# install only the packages you need
# this is the bit which fails for most other methods of installation
RUN tlmgr install xcolor pgf fancyhdr parskip babel-english units lastpage mdwtools comment genmisc fontawesome

答案2

问题是它wget实际上并未安装在 Alpine Linux 上,正如您可以通过以下 shell 命令和输出看到的那样:

/ # ls -al $(which wget)
lrwxrwxrwx    1 root     root            12 May 29 14:20 /usr/bin/wget -> /bin/busybox

wget实际上只是符号链接到 BusyBox。busybox --help显示:

BusyBox 是一个多调用二进制文件,它将许多常见的 Unix 实用程序组合成一个可执行文件。大多数人会为他们想要使用的每个函数创建一个到 busybox 的链接,而 BusyBox 会像调用它时一样运行。

您可以在 Alpine Linux 下按如下方式安装 TeXLive:

/ # apk update
/ # apk upgrade
/ # apk add --no-cache perl wget
/ # wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
/ # tar -xzf install-tl-unx.tar.gz
/ # cd install-tl-20*
/ # ./install-tl

相关内容