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/* \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& truncate -s 0 /var/log/*log && 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 COPY . /app
WORKDIR /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" .marp
chown -R "$EXT_UID:$EXT_GID" /home/appuser 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 if [ "$1" = "shell" ]; then
exec bash exec bash
else else

View file

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