Skip to content

Commit

Permalink
Tweaks to building documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mmguero committed Oct 6, 2022
1 parent 9a0661c commit 19b7ff9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ arkime-logs
arkime-raw
nginx/nginx_ldap.conf
pcap
_site
scripts
!scripts/malcolm_common.py
zeek-logs
Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/nginx.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ FROM ghcr.io/mmguero-dev/jekyll:latest as docbuild
ARG VCS_REVISION
ENV VCS_REVISION $VCS_REVISION

ADD README.md _includes _layouts _site _config.yml Gemfile docs /site/
ADD README.md _includes _layouts _config.yml Gemfile docs /site/

WORKDIR /site

Expand Down
28 changes: 27 additions & 1 deletion scripts/documentation_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ LOG_BASE_DIR=$(pwd)
while getopts 'v' OPTION; do
case "$OPTION" in
v)
set -x
VERBOSE_FLAG="-v"
;;

Expand Down Expand Up @@ -59,6 +60,18 @@ else
exit 1
fi

################################################################################
# cleanup temporary directory, if any
WORKDIR="$(mktemp -d -t malcolm-docs-XXXXXX)"

function _cleanup {
if [[ -d "$WORKDIR" ]] && ! rm -rf "$WORKDIR"; then
echo "Failed to remove temporary directory '$WORKDIR'" >&2
fi
}

trap "_cleanup" EXIT

# force-navigate to Malcolm base directory (parent of scripts/ directory)
RUN_PATH="$(pwd)"
SCRIPT_PATH="$($DIRNAME $($REALPATH -e "${BASH_SOURCE[0]}"))"
Expand All @@ -67,9 +80,22 @@ pushd "$SCRIPT_PATH/.." >/dev/null 2>&1
# clean up old documentation builds
[[ -d ./_site/ ]] && rm -rf ./_site/

# copy just what's needed for documentation into temporary working directory and build there
cp $VERBOSE_FLAG -r README.md _includes _layouts _config.yml Gemfile docs "$WORKDIR"
pushd "$WORKDIR" >/dev/null 2>&1

# run jekyll docker container to generate HTML version of the documentation
$DOCKER_BIN run --rm -v "$(pwd)":/site --entrypoint="docker-entrypoint.sh" ghcr.io/mmguero-dev/jekyll bundle exec jekyll build
$DOCKER_BIN run --rm -v "$(pwd)":/site --entrypoint="docker-entrypoint.sh" ghcr.io/mmguero-dev/jekyll:latest bundle exec jekyll build

# clean up some files no longer needed
find ./_site/ -type f -name "*.md" -delete

# TODO: can we get this to run mapping UID so it doesn't have to be sudo'd?
$SUDO_CMD chown -R $(id -u):$(id -g) ./_site/

popd >/dev/null 2>&1

# copy built documentation from work directory
cp $VERBOSE_FLAG -r "$WORKDIR"/_site/ ./

popd >/dev/null 2>&1

0 comments on commit 19b7ff9

Please sign in to comment.