docmachine-containers/docker/entrypoint.sh
Glenn Y. Rolland 6a2abc6235 feat(docker): modularize Docker setup for docs and slides
Introduces distinct Dockerfiles for documentation and slide projects, enhancing modularity and build efficiency. The previous monolithic structure was less flexible and caused longer build times.

- Added `DOCMACHINE_DOCS_ENABLE` and `DOCMACHINE_SLIDES_ENABLE` env variables to toggle features.
- Created `docker/Dockerfile.docs` for documentation builds, including necessary tools and dependencies.
- Created `docker/Dockerfile.slides` for slide builds to streamline setup.
- Updated main Dockerfile to include `python-is-python3` for compatibility, removing redundant symlinks.
- Enhanced LaTeX tools by adding `texlive-xetex` and extra fonts for improved PDF output.
2025-03-27 10:14:38 +01:00

72 lines
1.6 KiB
Bash
Executable file

#!/bin/sh
set -u
set -e
ARGS="$*"
echo "Arguments: $ARGS"
EXT_UID="${EXT_UID:-999}"
EXT_GID="${EXT_GID:-999}"
DOCMACHINE_DOCS_ENABLE="${DOCMACHINE_DOCS_ENABLE:-1}"
DOCMACHINE_SLIDES_ENABLE="${DOCMACHINE_SLIDES_ENABLE:-1}"
gx_workdir_prepare() {
# Create missing directories
mkdir -p _cache
mkdir -p _build
if [ "$DOCMACHINE_SLIDES_ENABLE" = "1" ]; then
mkdir -p .marp
fi
mkdir -p /home/appuser
}
gx_users_prepare() {
# Create user with given ID if needed
if ! grep -q "^[^:]*:[^:]*:$EXT_UID:" /etc/group ; then
groupadd -g "$EXT_GID" appuser
fi
# Create group with given ID if needed
if ! grep -q "^[^:]*:[^:]*:$EXT_UID:" /etc/passwd ; then
useradd -r -u "$EXT_UID" -g appuser appuser
fi
# echo "Setting permissions to $EXT_UID:$EXT_GID"
# chown -R "$EXT_UID:$EXT_GID" _cache
# chown -R "$EXT_UID:$EXT_GID" _build
# chown -R "$EXT_UID:$EXT_GID" .marp
# chown -R "$EXT_UID:$EXT_GID" /home/appuser
# chown -R "$EXT_UID:$EXT_GID" slides
# chown -R "$EXT_UID:$EXT_GID" docs
}
gx_docs_configure() {
# Patch mkdocs configuration
if [ -f mkdocs-patch.yml ]; then
# patch reference mkdocs with user-provided options
yq eval-all '. as $item ireduce ({}; . * $item)' \
mkdocs-source.yml \
mkdocs-patch.yml \
> mkdocs.yml
else
# use reference mkdocs only (no options)
ln -s mkdocs-source.yml mkdocs.yml
fi
}
##
## Main
##
gx_workdir_prepare
gx_users_prepare
if [ "$DOCMACHINE_DOCS_ENABLE" = "1" ]; then
gx_docs_configure
fi
if [ "$1" = "supershell" ]; then
exec bash
else
# exec gosu "$EXT_UID:$EXT_GID" make "$@"
exec make "$@"
fi