I am trying to dockerize my LaTeX distribution using Alpine on my MacBook Pro with an M3 Max chip.
Dockerfile
FROM alpine:3.21
ENV PATH=/usr/local/texlive/bin/aarch64-linuxmusl:$PATH
ARG TL_MIRROR=https://mirror.init7.net/ctan/systems/texlive/tlnet
WORKDIR /data
COPY texlive.profile /tmp/
RUN apk add --no-cache perl wget && \
wget $TL_MIRROR/install-tl-unx.tar.gz && \
mkdir /tmp/install-tl && \
tar -xzf install-tl-unx.tar.gz -C /tmp/install-tl --strip-components=1 && \
/tmp/install-tl/install-tl --profile=/tmp/texlive.profile && \
tlmgr update --self && \
tlmgr option repository $TL_MIRROR && \
tlmgr install \
biber \
biblatex \
bookmark \
booktabs \
ellipsis \
enumitem \
fbb \
fontawesome \
hyperref \
kpfonts \
l3packages \
latex \
latex-bin \
latex-tools-dev \
latexmk \
listings \
ly1 \
mathtools \
memoir \
microtype \
nth \
pgfplots \
thmtools \
ulem \
xcolor \
xfrac \
xkeyval \
xpatch \
xstring && \
apk del --no-cache wget && \
rm -rf \
/var/cache/apk/* \
/var/lib/apt/lists/* \
/tmp/* \
/var/tmp/* \
install-tl-unx.tar.gz
texlive.profile
selected_scheme scheme-minimal
TEXDIR /usr/local/texlive
TEXMFCONFIG ~/.texlive/texmf-config
TEXMFHOME ~/texmf
TEXMFLOCAL /usr/local/texlive/texmf-local
TEXMFSYSCONFIG /usr/local/texlive/texmf-config
TEXMFSYSVAR /usr/local/texlive/texmf-var
TEXMFVAR ~/.texlive/texmf-var
tlpdbopt_install_docfiles 0
tlpdbopt_install_srcfiles 0
When I try to build the image, I get an error: /tmp/install-tl/install-tl: Quitting, no binary platform specified/available.
In the first two lines, I have tried various permutations, e.g.:
FROM alpine:3.21
FROM arm64v8/alpine:3.21
and
ENV PATH=/usr/local/texlive/bin/aarch64-linuxmusl:$PATH
ENV PATH=/usr/local/texlive/bin/arm64-linuxmusl:$PATH
ENV PATH=/usr/local/texlive/bin/aarch64-linux:$PATH
ENV PATH=/usr/local/texlive/bin/arm64-linux:$PATH
But the error remains.
Note that using amd64/x86_64 works:
FROM --platform=linux/amd64 alpine:3.21
ENV PATH=/usr/local/texlive/bin/x86_64-linuxmusl:$PATH
What is the best way to dockerize my LaTeX distribution on aarch64?
I managed to resolve the issue by using a custom binary set as follows:
Dockerfile
FROM alpine:3.21
ENV PATH=/usr/local/texlive/bin/custom:$PATH
ARG TL_MIRROR=https://mirror.init7.net/ctan/systems/texlive/tlnet
WORKDIR /data
COPY texlive.profile /tmp/
RUN apk add --no-cache perl wget xz && \
wget https://ftp.math.utah.edu/pub/texlive-utah/bin/aarch64-alpine319.tar.xz && \
mkdir /tmp/custombin && \
tar -xvf aarch64-alpine319.tar.xz -C /tmp/custombin --strip-components=1 && \
cp /usr/bin/wget /usr/bin/xz /tmp/custombin && \
wget $TL_MIRROR/install-tl-unx.tar.gz && \
mkdir /tmp/install-tl && \
tar -xvf install-tl-unx.tar.gz -C /tmp/install-tl --strip-components=1 && \
/tmp/install-tl/install-tl --custom-bin=/tmp/custombin --profile=/tmp/texlive.profile && \
tlmgr update --self && \
tlmgr option repository $TL_MIRROR && \
tlmgr install \
biber \
biblatex \
bookmark \
booktabs \
ellipsis \
enumitem \
fbb \
fontawesome \
hyperref \
kpfonts \
l3packages \
latex \
latex-bin \
latex-tools-dev \
latexmk \
listings \
ly1 \
mathtools \
memoir \
microtype \
nth \
pgfplots \
thmtools \
ulem \
xcolor \
xfrac \
xkeyval \
xpatch \
xstring && \
apk del --no-cache wget xz && \
rm -rf \
/var/cache/apk/* \
/var/lib/apt/lists/* \
/tmp/* \
/var/tmp/* \
aarch64-alpine319.tar.xz \
install-tl-unx.tar.gz
This image works, and I can compile as expected.
The only issue is that the resulting image is 445 MB whereas the x86_64 version was around 250 MB.
I am now using the Docker extension Dive-In to investigate the image further.