Skip to content

Commit

Permalink
feat: initial tests of building debian based images
Browse files Browse the repository at this point in the history
  • Loading branch information
xu-cheng committed Jun 5, 2024
1 parent e3ededa commit a88ad7a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 45 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
env:
SCHEME: ${{ matrix.scheme }}
TAG: ghcr.io/xu-cheng/texlive-${{ matrix.scheme }}
TAG: ghcr.io/xu-cheng/texlive-${{ matrix.scheme }}-debian
steps:
- name: Get version
run: |
Expand All @@ -34,10 +34,10 @@ jobs:
context: .
build-args: scheme=${{ env.SCHEME }}
load: true
tags: texlive-${{ env.SCHEME }}
tags: texlive-${{ env.SCHEME }}-debian
- name: Test pdflatex
run: |
docker run --rm texlive-$SCHEME pdflatex --version
docker run --rm texlive-$SCHEME-debian pdflatex --version
cat <<EOF >ref.bib
@book{knuth1997,
author = {Donald E. Knuth},
Expand All @@ -58,8 +58,8 @@ jobs:
\printbibliography
\end{document}
EOF
docker run --rm -v "$(pwd):/data" -w /data texlive-$SCHEME \
python3 /opt/texlive/texdir/bin/x86_64-linuxmusl/texliveonfly \
docker run --rm -v "$(pwd):/data" -w /data texlive-$SCHEME-debian \
python3 /opt/texlive/bin/texliveonfly \
-c latexmk -a "-g -pdf -halt-on-error -interaction=nonstopmode" test.tex
file test.pdf | grep -q ' PDF '
- name: Test latexindent
Expand All @@ -71,8 +71,7 @@ jobs:
test
\end{document}
EOF
docker run --rm -v $(pwd):/data -w /data texlive-$SCHEME latexindent test.tex
if: "matrix.scheme == 'full'"
docker run --rm -v $(pwd):/data -w /data texlive-$SCHEME-debian latexindent test.tex
- name: Login
uses: docker/login-action@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:latest
FROM debian:bookworm-slim
ARG scheme=full

LABEL \
Expand All @@ -7,7 +7,7 @@ LABEL \
org.opencontainers.image.source="https://github.com/xu-cheng/latex-docker" \
org.opencontainers.image.licenses="MIT"

ENV PATH="/opt/texlive/texdir/bin/x86_64-linuxmusl:${PATH}"
ENV PATH="/opt/texlive/bin:${PATH}"

COPY \
LICENSE \
Expand Down
74 changes: 40 additions & 34 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#!/usr/bin/env bash

set -e
set -eo pipefail

scheme="$1"

Expand All @@ -23,34 +23,52 @@ retry() {
done
}

case "$(uname -m)" in
x86_64)
echo "binary_x86_64-linux 1" >>/texlive.profile
TEX_ARCH=x86_64-linux
;;

aarch64)
echo "binary_aarch64-linux 1" >>/texlive.profile
TEX_ARCH=aarch64-linux
;;

*)
echo "Unknown arch: $(uname -m)" >&2
exit 1
;;
esac

echo "==> Install system packages"
apk --no-cache add \
bash \
export DEBIAN_FRONTEND=noninteractive
apt-get update -y
apt-get upgrade -y
apt-get install -y \
curl \
fontconfig \
fonts-freefont-ttf \
ghostscript \
git \
gnupg \
gnuplot \
git \
graphviz \
make \
openjdk21-jre-headless \
openjdk-17-jre-headless \
perl \
py-pygments \
python3 \
tar \
ttf-freefont \
wget \
xz
python3-pygments \
tar

# Dependencies needed by latexindent
apk --no-cache add \
perl-unicode-linebreak \
perl-yaml-tiny
apk --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing add \
perl-file-homedir
apt-get install -y \
libfile-homedir-perl \
libunicode-linebreak-perl \
libyaml-tiny-perl

echo "==> Install TeXLive"
mkdir -p /opt/texlive/
ln -sf "/opt/texlive/texdir/bin/$TEX_ARCH" /opt/texlive/bin
mkdir -p /tmp/install-tl
cd /tmp/install-tl
MIRROR_URL="$(curl -fsS -w "%{redirect_url}" -o /dev/null https://mirror.ctan.org/)"
Expand All @@ -66,34 +84,22 @@ tar --strip-components 1 -zxf /tmp/install-tl/install-tl-unx.tar.gz -C /tmp/inst
retry 3 /tmp/install-tl/installer/install-tl -scheme "scheme-$scheme" -profile=/texlive.profile

# Install additional packages for non full scheme
if [ "$scheme" != "full" ]; then
if [[ $scheme != "full" ]]; then
tlmgr install \
collection-bibtexextra \
collection-binextra \
collection-fontsrecommended \
collection-fontutils \
biber \
biblatex \
latexmk \
texliveonfly \
xindy
collection-fontutils
fi

# https://github.com/xu-cheng/latex-action/issues/32#issuecomment-626086551
ln -sf /opt/texlive/texdir/texmf-dist/scripts/xindy/xindy.pl /opt/texlive/texdir/bin/x86_64-linuxmusl/xindy
ln -sf /opt/texlive/texdir/texmf-dist/scripts/xindy/texindy.pl /opt/texlive/texdir/bin/x86_64-linuxmusl/texindy
curl -OL https://sourceforge.net/projects/xindy/files/xindy-source-components/2.4/xindy-kernel-3.0.tar.gz
tar xf xindy-kernel-3.0.tar.gz
cd xindy-kernel-3.0/src
apk add clisp --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community
make
cp -f xindy.mem /opt/texlive/texdir/bin/x86_64-linuxmusl/
cd -

# System font configuration for XeTeX and LuaTeX
# Ref: https://www.tug.org/texlive/doc/texlive-en/texlive-en.html#x1-330003.4.4
ln -s /opt/texlive/texdir/texmf-var/fonts/conf/texlive-fontconfig.conf /etc/fonts/conf.d/09-texlive.conf
fc-cache -fv

echo "==> Clean up"
apt-get autoremove -y --purge
apt-get clean -y
rm -rf \
/opt/texlive/texdir/install-tl \
/opt/texlive/texdir/install-tl.log \
Expand Down
2 changes: 0 additions & 2 deletions texlive.profile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ TEXMFSYSCONFIG /opt/texlive/texdir/texmf-config
TEXMFVAR /root/texlive/texmf-var
TEXMFCONFIG /root/texlive/texmf-config
TEXMFHOME /root/texmf
binary_x86_64-linuxmusl 1
binary_x86_64-linux 0
instopt_adjustpath 0
instopt_adjustrepo 1
instopt_letter 0
Expand Down

0 comments on commit a88ad7a

Please sign in to comment.