Skip to content

Commit

Permalink
fix(ci): Resolve CTAN mirror outside of Docker build
Browse files Browse the repository at this point in the history
Can't seem to resolve mirrors.ctan.org from within `docker build`.
For reasons. (?)

Credits: https://github.com/zauguin/install-texlive via @koppor
  • Loading branch information
reitzig committed Mar 11, 2024
1 parent d7b7eb1 commit 8da93d5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/scripts/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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}" \
Expand All @@ -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}" \
Expand All @@ -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}"
Expand Down
5 changes: 5 additions & 0 deletions .github/scripts/build-installer-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}" \
.
Expand Down
13 changes: 11 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ RUN apk --no-cache add \
xz=${XZ_VERSION} \
zlib=${ZLIB_VERSION}

RUN wget https://mirrors.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
Expand All @@ -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"
Expand Down

0 comments on commit 8da93d5

Please sign in to comment.