Files
docs/publishing/deploy.sh
T
inference-bot a81249eda2 publishing: deploy the docs to their own Surfer app at docs.inference.coop
The docs now have a dedicated Cloudron app (io.cloudron.surfer,
location docs.inference.coop, id 85b7ce06-e2af-49a4-bd4f-a9c2e692e3ab)
serving /app/data/public. deploy.sh writes there and nowhere else; the
two copies inside the marketing Surfer app (public-docs and
public/docs) have been deleted, so there is one canonical location.

SURFER_APP now defaults to docs.inference.coop and DOCS_DEST to
/app/data/public.
2026-11-03 21:39:41 +00:00

88 lines
3.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Publish the built documentation site to the docs Surfer app.
#
# The docs have their OWN Cloudron app now:
#
# Cloudron app: docs.inference.coop (io.cloudron.surfer, id 85b7ce06-e2af-49a4-bd4f-a9c2e692e3ab)
# served at: https://docs.inference.coop/
# on disk: /app/data/public (Surfer's "Default" site)
#
# They used to be a directory inside the marketing Surfer app
# (inference.coop, id 55f5f904-...), reachable at /app/data/public-docs and
# /app/data/public/docs. Both of those copies were deleted once this app was
# serving, so there is exactly one canonical location and nothing to drift.
#
# Mechanism (evidence: Cloudron app "Surfer" io.cloudron.surfer 7.4.1, and
# repos/website/deploy.sh, which deploys the marketing site the same way):
# pipe a tar of the build output into the container via `cloudron exec`, which
# needs only the Cloudron API token — no WebDAV token, SFTP credentials or SSH.
# The tar is spooled to a file inside the container first; piping it straight
# into `tar xf -` twice would leave the second extraction with an empty stdin.
#
# Usage:
# CLOUDRON_TOKEN=... publishing/deploy.sh
#
# Env:
# CLOUDRON_TOKEN (required) Cloudron API token
# CLOUDRON_SERVER default my.inference.coop
# SURFER_APP default docs.inference.coop (the docs app's location)
# DOCS_DEST default /app/data/public (Surfer's Default site root)
# SITE_DIR default <repo>/.site-build
set -euo pipefail
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SITE_DIR="${SITE_DIR:-$REPO_DIR/.site-build}"
SERVER="${CLOUDRON_SERVER:-my.inference.coop}"
APP="${SURFER_APP:-docs.inference.coop}"
DEST="${DOCS_DEST:-/app/data/public}"
CLOUDRON_BIN="${CLOUDRON_BIN:-$(command -v cloudron || true)}"
if [ -z "$CLOUDRON_BIN" ] && [ -x "$HOME/.local/bin/cloudron" ]; then
CLOUDRON_BIN="$HOME/.local/bin/cloudron"
fi
: "${CLOUDRON_BIN:?cloudron CLI not found (set CLOUDRON_BIN or add it to PATH)}"
# The cloudron CLI is a node script (`#!/usr/bin/env node`); under systemd the
# PATH may not contain the host's node, so look in the usual places.
if ! command -v node >/dev/null 2>&1; then
for dir in "$HOME"/.hermes/tools/node*/bin /usr/local/bin; do
if [ -x "$dir/node" ]; then export PATH="$dir:$PATH"; break; fi
done
fi
: "${CLOUDRON_TOKEN:?CLOUDRON_TOKEN is required (the Cloudron API token)}"
if [ ! -f "$SITE_DIR/index.html" ]; then
echo "No build found at $SITE_DIR — run publishing/build.sh first." >&2
exit 1
fi
# Build metadata: written into the output so a deploy can be verified from the
# served site itself (which push produced it, and when).
COMMIT="$(git -C "$REPO_DIR" rev-parse HEAD 2>/dev/null || echo unknown)"
COMMIT_SHORT="$(git -C "$REPO_DIR" rev-parse --short HEAD 2>/dev/null || echo unknown)"
BUILT_AT="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
cat > "$SITE_DIR/meta.json" <<EOF
{
"commit": "$COMMIT",
"commit_short": "$COMMIT_SHORT",
"built_at": "$BUILT_AT",
"generator": "mkdocs-material (publishing/build.sh)",
"source": "https://git.inference.coop/co-op/docs"
}
EOF
echo "Deploying $SITE_DIR (commit $COMMIT_SHORT) -> $SERVER:$APP"
echo " $DEST (docs.inference.coop)"
tar cf - -C "$SITE_DIR" . | \
"$CLOUDRON_BIN" --server "$SERVER" --token "$CLOUDRON_TOKEN" exec --app "$APP" -- \
sh -c "set -e
cat > /tmp/docs-site.tar
rm -rf '$DEST' && mkdir -p '$DEST' && tar xf /tmp/docs-site.tar -C '$DEST'
rm -f /tmp/docs-site.tar"
echo "Done:"
echo " https://docs.inference.coop/"