#!/usr/bin/env bash # Build one site's static archive and publish it into the volume the `site` # service serves. # # docker compose exec editor /repo/docker/publish-site.sh # # A wrapper over the three publish stages, nothing more (release 18): # # archilyzer publish index the shared index, stats, templates # archilyzer publish build the site's bundle in the builds volume # archilyzer publish deploy --to local copied into ARCHILYZER_SITE_OUT # # Each stage is a no-op when it is already fresh, so running this twice costs # seconds; each takes the publish lock, so it waits for (never races) a stage # the editor is running. Run them one at a time for more control — the same # commands, through `docker compose exec editor pnpm archilyzer publish …`. # # Why the export site is built at run time rather than baked: it is a static # render OF A CORPUS, and there is no corpus at image-build time. set -euo pipefail SITE_ID="${1:-${SITE_ID:-}}" SITE_OUT="${ARCHILYZER_SITE_OUT:-/data/builds/site}" if [ -z "${SITE_ID}" ]; then echo "usage: publish-site.sh " >&2 echo >&2 echo "configured sites:" >&2 ls -1 "${TRANSCRIPTS_DIR:-/data/transcripts}/sites" 2>/dev/null | grep -v '^_' | sed 's/^/ /' >&2 || echo " (none yet — create one in the editor under Sites)" >&2 exit 2 fi # A PRIVATE site (site.json `audience: "private"`) is never deployed, and the # volume this fills is what the `site` service serves. The deploy stage refuses # it too (over the built corpus.json); refusing here first saves the build. SITE_JSON="${SITES_DIR:-${TRANSCRIPTS_DIR:-/data/transcripts}/sites}/${SITE_ID}/site.json" if grep -Eq '"audience"[[:space:]]*:[[:space:]]*"private"' "${SITE_JSON}" 2>/dev/null; then echo "[publish-site] REFUSED — site '${SITE_ID}' is private (audience: private): it is built for reading on this machine and is never deployed. Nothing was published to ${SITE_OUT}. Build it without publishing: pnpm archilyzer publish build ${SITE_ID}" >&2 exit 1 fi cd /repo archilyzer() { pnpm --filter yt-dlp-transcript-common exec tsx bin/archilyzer.ts "$@" } archilyzer publish index archilyzer publish build "${SITE_ID}" archilyzer publish deploy "${SITE_ID}" --to local echo "[publish-site] the site service serves ${SITE_OUT} immediately; no restart needed."