Skip to content

Commit

Permalink
Use file DEPENDS.txt to produce minimal image in CI for pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Witiko committed Jul 12, 2024
1 parent 30597fb commit 499fbef
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 8 deletions.
40 changes: 35 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ARG DEPENDENCIES="\
python3-pygments \
python3-venv \
retry \
ruby \
unzip \
wget \
zip \
Expand All @@ -35,6 +34,13 @@ ARG DEV_DEPENDENCIES="\
vim \
"

ARG TEXLIVE_DEPENDENCIES="\
l3kernel \
latex \
latexmk \
luatex \
"

ARG BINARY_DIR=/usr/local/bin
ARG BUILD_DIR=/git-repo
ARG INSTALL_DIR=/usr/local/texlive/texmf-local
Expand All @@ -47,6 +53,7 @@ ARG DEV_IMAGE=false
FROM $FROM_IMAGE:$TEXLIVE_TAG as build

ARG DEPENDENCIES
ARG TEXLIVE_DEPENDENCIES

ARG BUILD_DIR
ARG INSTALL_DIR
Expand All @@ -67,7 +74,7 @@ set -o errexit
set -o nounset
set -o xtrace

# Install dependencies
# Install OS dependencies
apt-get -qy update
apt-get -qy install --no-install-recommends ${DEPENDENCIES}

Expand All @@ -80,8 +87,12 @@ then
retry -t 30 -d 60 tlmgr update --self --all --repository ftp://ftp.cstug.cz/pub/tex/local/tlpretest/
fi

# Generate the ConTeXt file database
mtxrun --generate
# Install basic TeX Live dependencies
if echo ${TEXLIVE_TAG} | grep -q latest-minimal
then
retry -t 30 -d 60 tlmgr install ${TEXLIVE_DEPENDENCIES}
tlmgr path add
fi

# Uninstall the distribution Markdown package
rm -rfv ${PREINSTALLED_DIR}/tex/luatex/markdown/
Expand Down Expand Up @@ -112,7 +123,11 @@ cp ${BUILD_DIR}/t-markdown.tex ${INSTALL_DIR}/tex/
cp ${BUILD_DIR}/t-markdownthemewitiko_markdown_defaults.tex ${INSTALL_DIR}/tex/context/third/markdown/

# Generate the ConTeXt file database
mtxrun --generate
if echo ${TEXLIVE_TAG} | grep -q -v latest-minimal
then
export TEXMF="$(readlink -f ${PREINSTALLED_DIR}/..)"
mtxrun --generate
fi

# Reindex the TeX directory structure
texhash
Expand Down Expand Up @@ -145,6 +160,9 @@ ENV DEBIAN_FRONTEND=noninteractive
ENV TERM=xterm
ENV TEXMFLOCAL=${INSTALL_DIR}

COPY --from=build ${BUILD_DIR}/DEPENDS.txt ${BUILD_DIR}/DEPENDS.txt
COPY --from=build ${BUILD_DIR}/tests/DEPENDS.txt ${BUILD_DIR}/tests/DEPENDS.txt

RUN <<EOF

set -o errexit
Expand Down Expand Up @@ -172,6 +190,13 @@ then
retry -t 30 -d 60 tlmgr update --self --all --repository ftp://ftp.cstug.cz/pub/tex/local/tlpretest/
fi

# Install TeX Live dependencies
if echo ${TEXLIVE_TAG} | grep -q latest-minimal
then
retry -t 30 -d 60 tlmgr install $(awk '{ print $2 }' ${BUILD_DIR}/DEPENDS.txt ${BUILD_DIR}/tests/DEPENDS.txt | sort -u)
tlmgr path add
fi

# Uninstall the distribution Markdown package
rm -rfv ${PREINSTALLED_DIR}/tex/luatex/markdown/
rm -rfv ${PREINSTALLED_DIR}/scripts/markdown/
Expand Down Expand Up @@ -200,9 +225,14 @@ set -o xtrace
chmod +x ${BINARY_DIR}/markdown-cli

# Generate the ConTeXt file database
export TEXMF="$(readlink -f ${PREINSTALLED_DIR}/..)"
echo "export TEXMF=$TEXMF" >> /root/.bashrc
mtxrun --generate

# Reindex the TeX directory structure
texhash

# Remove the build directory
rm -rfv ${BUILD_DIR}

EOF
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ INSTALLABLES=markdown.lua markdown-cli.lua markdown.tex markdown.sty t-markdown.
markdownthemewitiko_markdown_defaults.sty t-markdownthemewitiko_markdown_defaults.tex
EXTRACTABLES=$(INSTALLABLES) $(MARKDOWN_USER_MANUAL) $(TECHNICAL_DOCUMENTATION_RESOURCES) \
$(DEPENDENCIES)
MAKEABLES=$(TECHNICAL_DOCUMENTATION) $(USER_MANUAL) $(INSTALLABLES) $(EXAMPLES)
MAKEABLES=$(TECHNICAL_DOCUMENTATION) $(USER_MANUAL) $(INSTALLABLES) $(EXAMPLES) $(DEPENDENCIES)
RESOURCES=$(DOCUMENTATION) $(EXAMPLES_RESOURCES) $(EXAMPLES_SOURCES) $(EXAMPLES) \
$(MAKES) $(READMES) $(INSTALLER) $(DTXARCHIVE) $(TESTS) $(DEPENDENCIES)
EVERYTHING=$(RESOURCES) $(INSTALLABLES) $(LIBRARIES)
Expand All @@ -70,6 +70,9 @@ ifndef DOCKER_TEXLIVE_TAG
endif
ifeq ($(DOCKER_DEV_IMAGE), true)
DOCKER_TAG_POSTFIX=-no_docs
ifeq ($(DOCKER_TEXLIVE_TAG), latest)
DOCKER_TEXLIVE_TAG=latest-minimal
endif
endif
DOCKER_TEMPORARY_IMAGE=ghcr.io/witiko/markdown
DOCKER_TEMPORARY_TAG=$(VERSION)-$(DOCKER_TEXLIVE_TAG)$(DOCKER_TAG_POSTFIX)
Expand Down Expand Up @@ -131,9 +134,11 @@ $(EXTRACTABLES): $(INSTALLER) $(DTXARCHIVE)
-e 's#(((LASTMODIFIED)))#$(LASTMODIFIED)#g' \
$(INSTALLABLES)
sed -i \
-e '/\\ExplSyntaxOff/{N;/\\ExplSyntaxOn/d;}' \
-e '/\\ExplSyntaxOff/ { N; /\\ExplSyntaxOn/d; }' \
$(INSTALLABLES)
grep -v '^#' $(DEPENDENCIES) | sort -u -o $(DEPENDENCIES)
( \
sed -n '/^#/ ! { s/\s*#.*//; p }' $(DEPENDENCIES); \
) | sort -u -o $(DEPENDENCIES)

# This target produces the version file.
$(VERSION_FILE): force
Expand Down
10 changes: 10 additions & 0 deletions examples/DEPENDS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
soft babel-english
soft collection-context
soft collection-latex
soft collection-latexrecommended
soft collection-luatex
soft dvipng
soft latex-bin
soft make4ht
soft optex
soft xetex
3 changes: 3 additions & 0 deletions markdown.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,7 @@ soft paralist
% \end{markdown}
% \begin{macrocode}
soft latex
soft epstopdf-pkg # required by `latex`
% \end{macrocode}
% \begin{markdown}
%
Expand All @@ -1382,6 +1383,8 @@ soft fancyvrb
% \end{markdown}
% \begin{macrocode}
soft csvsimple
soft pgf # required by `csvsimple`, which loads `pgfkeys.sty`
soft tools # required by `csvsimple`, which loads `shellesc.sty`
% \end{macrocode}
% \begin{markdown}
%
Expand Down
3 changes: 3 additions & 0 deletions tests/DEPENDS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
soft context
soft latex-bin
soft xetex

0 comments on commit 499fbef

Please sign in to comment.