From a67c44a539de8d1b830dfcb444b1df3fee234003 Mon Sep 17 00:00:00 2001 From: Raphael Reitzig <4246780+reitzig@users.noreply.github.com> Date: Mon, 11 Mar 2024 23:11:52 +0100 Subject: [PATCH] fix(ci): Resolve CTAN mirror outside of Docker build Can't seem to resolve mirrors.ctan.org from within 'docker build'. Don't know why. Credits: https://github.com/zauguin/install-texlive via @koppor --- .github/scripts/build-image.sh | 7 +++++++ .github/scripts/build-installer-image.sh | 5 +++++ Dockerfile | 13 +++++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/scripts/build-image.sh b/.github/scripts/build-image.sh index bf086d2..45df3e1 100755 --- a/.github/scripts/build-image.sh +++ b/.github/scripts/build-image.sh @@ -7,6 +7,10 @@ set -eu installer_image=${TEXLIVE_INSTALLER_IMAGE:-'texlive-installer:latest'} image_tag_list="${IMAGE_TAG_LIST:-/dev/stdout}" +# NB: Can't seem to resolve mirrors.ctan.org from within `docker build`, so do it here: +ctan_mirror="$(curl -Ls -o /dev/null -w '%{url_effective}' https://mirrors.ctan.org)" +echo "Will use CTAN mirror ${ctan_mirror}" + ref="${1}" profile="${2:-minimal}" commit_time="$(date --date="@$(git show -s --format=%ct HEAD)" --rfc-3339=seconds)" @@ -32,6 +36,7 @@ case "${ref}" in --cache-from "${installer_image}" \ --tag "$(make_docker_tag "${profile}" "${version}")" \ --tag "$(make_docker_tag "${profile}" latest)" \ + --build-arg "ctan_mirror=${ctan_mirror}" \ --build-arg "profile=${profile}" \ --build-arg "label_created=${commit_time}" \ --build-arg "label_version=${version}" \ @@ -46,6 +51,7 @@ case "${ref}" in docker build \ --cache-from "${installer_image}" \ --tag "$(make_docker_tag "${profile}" "${version}")" \ + --build-arg "ctan_mirror=${ctan_mirror}" \ --build-arg "profile=${profile}" \ --build-arg "label_created=${commit_time}" \ --build-arg "label_version=${version}" \ @@ -61,6 +67,7 @@ case "${ref}" in docker build \ --cache-from "${installer_image}" \ --tag "$(make_docker_tag "${profile}" "${version}")" \ + --build-arg "ctan_mirror=${ctan_mirror}" \ --build-arg "profile=${profile}" \ . make_docker_tag "${profile}" "${version}" >> "${image_tag_list}" diff --git a/.github/scripts/build-installer-image.sh b/.github/scripts/build-installer-image.sh index fed8459..aa01636 100755 --- a/.github/scripts/build-installer-image.sh +++ b/.github/scripts/build-installer-image.sh @@ -4,7 +4,12 @@ set -e installer_image=${TEXLIVE_INSTALLER_IMAGE:-'texlive-installer:latest'} +# NB: Can't seem to resolve mirrors.ctan.org from within `docker build`, so do it here: +ctan_mirror="$(curl -Ls -o /dev/null -w '%{url_effective}' https://mirrors.ctan.org)" +echo "Will use CTAN mirror ${ctan_mirror}" + docker build --no-cache \ + --build-arg "ctan_mirror=${ctan_mirror}" \ --target "texlive-installer" \ --tag "${installer_image}" \ . diff --git a/Dockerfile b/Dockerfile index 93c5b01..b903f9c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,7 +44,10 @@ RUN apk --no-cache add \ xz=${XZ_VERSION} \ zlib=${ZLIB_VERSION} -RUN wget mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz \ +ARG ctan_mirror="https://mirrors.ctan.org" +ENV CTAN_MIRROR=$ctan_mirror + +RUN wget "${CTAN_MIRROR}/systems/texlive/tlnet/install-tl-unx.tar.gz" \ && tar -xzf install-tl-unx.tar.gz \ && rm install-tl-unx.tar.gz \ && mv install-tl-* install-tl @@ -66,14 +69,20 @@ RUN tlversion=$(cat install-tl/release-texlive.txt | head -n 1 | awk '{ print $5 && ln -s /usr/local/texlive/${tlversion}/bin/x86_64-linuxmusl /usr/local/texlive/${tlversion}/bin/x86_64-linux \ && ln -s /usr/local/texlive/${tlversion}/bin/x86_64-linuxmusl/mktexlsr /usr/local/bin/mktexlsr +ARG ctan_mirror="https://mirrors.ctan.org" +ENV CTAN_MIRROR=$ctan_mirror + RUN ( cd install-tl \ && tlversion=$(cat release-texlive.txt | head -n 1 | awk '{ print $5 }') \ && sed -i "s/\${tlversion}/${tlversion}/g" ${profile}.profile \ - && ./install-tl -profile ${profile}.profile \ + && ./install-tl -repository="${CTAN_MIRROR}/systems/texlive/tlnet" -profile ${profile}.profile \ ) \ && rm -rf install-tl \ && tlmgr version | tail -n 1 > version \ && echo "Installed on $(date)" >> version + # && tlmgr option repository "${CTAN_MIRROR}" + # TODO: Determine if this is necessary -- shouldn't be, and + # we don't want to hammer the same mirror whenever the image is used! ARG src_dir="/work/src" ARG tmp_dir="/work/tmp"