feat: handle mkdocs patching

This commit is contained in:
Glenn Y. Rolland 2022-01-28 18:41:34 +01:00
parent da505d456b
commit 5515ff2d18
4 changed files with 24 additions and 3 deletions

View file

@ -21,6 +21,12 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& truncate -s 0 /var/log/*log
# External tools
# yq => manage YML
RUN curl -o /usr/local/bin/yq \
https://github.com/mikefarah/yq/releases/download/v4.18.1/yq_linux_amd64 \
&& chmod +x /usr/local/bin/yq
COPY . /app
WORKDIR /app

View file

@ -30,6 +30,16 @@ chown -R "$EXT_UID:$EXT_GID" _build
chown -R "$EXT_UID:$EXT_GID" .marp
chown -R "$EXT_UID:$EXT_GID" /home/appuser
# Patch mkdocs configuration
if [ -f mkdocs-patch.yml ]; then
yq \
eval-all
'. as $item ireduce ({}; . * $item)' \
mkdocs-source.yml \
mkdocs-patch.yml \
> mkdocs.yml
fi
if [ "$1" = "shell" ]; then
exec bash
else

View file

@ -77,10 +77,15 @@ else
fi
if [ -f "$BASEDIR/mkdocs.yml" ]; then
DOCKER_OPT_MKDOCS_CONFIG="-v $BASEDIR/mkdocs.yml:/app/mkdocs.yml"
echo "Mkdocs: detected mkdocs.yml file. Adding option to command line ($DOCKER_OPT_MKDOCS_CONFIG)"
>&2 echo "Mkdocs: detected mkdocs.yml file. Please rename to mkdocs-patch.yml"
exit 1
fi
if [ -f "$BASEDIR/mkdocs-patch.yml" ]; then
DOCKER_OPT_MKDOCS_CONFIG="-v $BASEDIR/mkdocs.yml:/app/mkdocs-patch.yml"
echo "Mkdocs: detected mkdocs-patch.yml file. Adding option to command line ($DOCKER_OPT_MKDOCS_CONFIG)"
else
echo "Mkdocs: no mkdocs.yml detected. Using default files"
echo "Mkdocs: no mkdocs-patch.yml detected. Using default files"
fi
if [ -d "$BASEDIR/slides" ]; then