Files
davideisinger.com/bin/build
David Eisinger a0a120b31e
Some checks failed
Deploy / deploy (push) Has been cancelled
Cache dither results
2026-04-08 23:54:20 -04:00

45 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
dither_dir="${repo_root}/bin/dither"
cache_dir="${DITHER_CACHE_DIR:-${repo_root}/.cache/dither}"
mkdir -p "${cache_dir}"
pushd "${dither_dir}" >/dev/null
bundle install
ROOT="${repo_root}/content" KEY="${repo_root}/secret.key" DITHER_CACHE_DIR="${cache_dir}" bundle exec rackup -p 4567 &
dither_pid=$!
popd >/dev/null
cleanup() {
if kill -0 "${dither_pid}" 2>/dev/null; then
kill "${dither_pid}" 2>/dev/null || true
wait "${dither_pid}" 2>/dev/null || true
fi
}
trap cleanup EXIT INT TERM
for _ in {1..50}; do
if (echo >/dev/tcp/localhost/4567) >/dev/null 2>&1; then
ready=1
break
fi
sleep 0.1
done
if [[ "${ready:-0}" -ne 1 ]]; then
echo "dither server did not start on port 4567" >&2
exit 1
fi
pushd "${repo_root}" >/dev/null
rm -rf public
HUGO_PARAMS_GIT_COMMIT="$(git rev-parse HEAD)" \
DITHER_SERVER=http://localhost:4567 \
hugo --minify
find public -name "*.enc" -type f -delete
find public/elsewhere -name "*.gmi" -type f -delete
popd >/dev/null