From 3d3da67c087618edff199db81ba869e201af3808 Mon Sep 17 00:00:00 2001 From: Boris Schrijver Date: Sun, 13 Oct 2024 14:21:45 +0200 Subject: [PATCH] Make Dockerfile arm64 compatible --- Dockerfile | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index b1e4afd..1bfa4a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM alpine:3.20.3 +FROM alpine:3.20.3 AS build # installation settings ARG TL_MIRROR="https://texlive.info/CTAN/systems/texlive/tlnet" -RUN apk add --no-cache perl curl fontconfig libgcc gnupg && \ +RUN apk add --no-cache perl curl fontconfig libgcc gnupg xz && \ mkdir "/tmp/texlive" && cd "/tmp/texlive" && \ wget "$TL_MIRROR/install-tl-unx.tar.gz" && \ tar xzvf ./install-tl-unx.tar.gz && \ @@ -18,12 +18,31 @@ RUN apk add --no-cache perl curl fontconfig libgcc gnupg && \ echo "TEXMFSYSVAR /opt/texlive/texmf-var" && \ echo "TEXMFHOME ~/.texmf" \ ) > "/tmp/texlive.profile" && \ - "./install-tl-"*"/install-tl" --location "$TL_MIRROR" -profile "/tmp/texlive.profile" && \ - rm -vf "/opt/texlive/install-tl" && \ - rm -vf "/opt/texlive/install-tl.log" && \ - rm -vrf /tmp/* + set -eux; cd "/tmp/texlive" && arch=$(uname -m); \ + case $arch in \ + x86_64) ARCHITECTURE='amd64' ;; \ + aarch64) ARCHITECTURE='arm64' ;; \ + *) echo >&2 "error: unsupported architecture ($arch)"; exit 1 ;;\ + esac; \ + echo "Architecture: $ARCHITECTURE"; \ + if [ "$ARCHITECTURE" = "amd64" ]; then \ + "./install-tl-"*"/install-tl" --location "$TL_MIRROR" -profile "/tmp/texlive.profile" && \ + ln -s /opt/texlive/bin/x86_64-linuxmusl /opt/texlive/bin/current; \ + fi; \ + if [ "$ARCHITECTURE" = "arm64" ]; then \ + wget https://ftp.math.utah.edu/pub/texlive-utah/bin/aarch64-alpine319.tar.xz && \ + tar xvf aarch64-alpine319.tar.xz && \ + "./install-tl-"*"/install-tl" --location "$TL_MIRROR" -profile "/tmp/texlive.profile" --custom-bin=/tmp/texlive/aarch64-alpine319 && \ + ln -s /opt/texlive/bin/custom /opt/texlive/bin/current; \ + fi; -ENV PATH="${PATH}:/opt/texlive/bin/x86_64-linuxmusl" +FROM alpine:3.20.3 AS final + +RUN apk add --no-cache perl fontconfig curl gnupg xz + +COPY --from=build /opt/texlive /opt/texlive + +ENV PATH="${PATH}:/opt/texlive/bin/current" ARG TL_SCHEME_BASIC="y" RUN if [ "$TL_SCHEME_BASIC" = "y" ]; then tlmgr install scheme-basic; fi