Skip to content

Commit

Permalink
build: MANUBOT_USE_DOCKER environment variable
Browse files Browse the repository at this point in the history
merges manubot/rootstock#449
closes manubot/rootstock#440

MANUBOT_USE_DOCKER=true instructs Manubot to use Docker for PDF export.
Defaults to DOCKER_RUNNING (whether Docker is running on the system).
  • Loading branch information
dhimmel authored Nov 30, 2021
1 parent 8086a39 commit 4ae5997
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ export TZ=Etc/UTC
# Default Python to read/write text files using UTF-8 encoding
export LC_ALL=en_US.UTF-8


# Set DOCKER_RUNNING to true if docker is running, otherwise false.
DOCKER_RUNNING="$(docker info &> /dev/null && echo "true" || (true && echo "false"))"

# Set option defaults
CI="${CI:-false}"
BUILD_PDF="${BUILD_PDF:-true}"
BUILD_DOCX="${BUILD_DOCX:-false}"
BUILD_LATEX="${BUILD_LATEX:-false}"
SPELLCHECK="${SPELLCHECK:-false}"
MANUBOT_USE_DOCKER="${MANUBOT_USE_DOCKER:-$DOCKER_RUNNING}"
# Pandoc's configuration is specified via files of option defaults
# located in the $PANDOC_DATA_DIR/defaults directory.
PANDOC_DATA_DIR="${PANDOC_DATA_DIR:-build/pandoc}"
Expand All @@ -41,13 +46,10 @@ pandoc --verbose \
--defaults=common.yaml \
--defaults=html.yaml

# Set DOCKER_RUNNING to a non-empty string if docker is running, otherwise null.
DOCKER_RUNNING="$(docker info &> /dev/null && echo "yes" || true)"

# Create PDF output (unless BUILD_PDF environment variable equals "false")
# The double-commas (,,) lowercase the variable.
# If Docker is not available, use WeasyPrint to create PDF
if [ "${BUILD_PDF,,}" != "false" ] && [ -z "$DOCKER_RUNNING" ]; then
if [ "${BUILD_PDF,,}" != "false" ] && [ "${MANUBOT_USE_DOCKER,,}" != "true" ]; then
echo >&2 "Exporting PDF manuscript using WeasyPrint"
if [ -L images ]; then rm images; fi # if images is a symlink, remove it
ln -s content/images
Expand All @@ -60,7 +62,7 @@ if [ "${BUILD_PDF,,}" != "false" ] && [ -z "$DOCKER_RUNNING" ]; then
fi

# If Docker is available, use athenapdf to create PDF
if [ "${BUILD_PDF,,}" != "false" ] && [ -n "$DOCKER_RUNNING" ]; then
if [ "${BUILD_PDF,,}" != "false" ] && [ "${MANUBOT_USE_DOCKER,,}" == "true" ]; then
echo >&2 "Exporting PDF manuscript using Docker + Athena"
if [ "${CI,,}" = "true" ]; then
# Incease --delay for CI builds to ensure the webpage fully renders, even when the CI server is under high load.
Expand Down

0 comments on commit 4ae5997

Please sign in to comment.