Clean, dependency-light front page. Only three things ship here: - index.html — two-button landing: Mobile -> mobile.html, Desktop -> pm_e-2.html - mobile.html — touch-first PWA (+ mobile-sessions.html practice journal) - pm_e-2.html — engraved-notation editor build.sh/deploy.sh trimmed to just these; deploy mirrors dist/ to the web root with rsync --delete. README/CLAUDE.md rewritten for the slim scope. The full project (PM_E-1 editor, embeddable widget, all hardware form-factor pages, Pico firmware editions, the Rust port, and the KiCad/SPICE hardware design) is preserved on the `concepts` branch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
63 lines
2.9 KiB
Bash
Executable file
63 lines
2.9 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Deploy the metronome to the Caddy web root that serves
|
|
# https://metronome.varasys.io
|
|
#
|
|
# Caddy config: /var/lib/caddy/Caddyfile (metronome.varasys.io:8443 block)
|
|
# Bind-mount: /etc/containers/systemd/caddy.container
|
|
#
|
|
# The web root is bind-mounted read-only into the Caddy container and served by
|
|
# file_server, which picks up changes immediately — so a plain file copy is all
|
|
# that's needed (no container restart). The web root is mirrored from dist/ with
|
|
# `rsync --delete`, so anything no longer built is removed from the live site.
|
|
set -euo pipefail
|
|
|
|
SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
DEST_DIR="/var/lib/caddy/www/metronome"
|
|
DIST_DIR="$SRC_DIR/dist"
|
|
|
|
[[ -f "$SRC_DIR/index.html" ]] || { echo "error: $SRC_DIR/index.html not found" >&2; exit 1; }
|
|
[[ -d "$DEST_DIR" ]] || { echo "error: web root $DEST_DIR is missing — is Caddy set up?" >&2; exit 1; }
|
|
|
|
# Assemble the self-contained pages (inlines assets/ into dist/). dist/ is git-ignored.
|
|
"$SRC_DIR/build.sh"
|
|
[[ -f "$DIST_DIR/index.html" ]] || { echo "error: build did not produce $DIST_DIR/index.html" >&2; exit 1; }
|
|
|
|
# --- compute build version ---------------------------------------------------
|
|
# Formal build: clean tree on a commit tagged v<VERSION> -> "X.Y.Z"
|
|
# Dev build: anything else -> "X.Y.Z-dev.<utc-ts>.<sha>[.dirty]"
|
|
VER="$(cat "$SRC_DIR/VERSION" 2>/dev/null || echo 0.0.0)"
|
|
cd "$SRC_DIR"
|
|
if git rev-parse --git-dir >/dev/null 2>&1; then
|
|
tag="$(git describe --exact-match --tags HEAD 2>/dev/null || true)"
|
|
dirty=""; [[ -n "$(git status --porcelain 2>/dev/null)" ]] && dirty=".dirty"
|
|
if [[ "$tag" == "v$VER" && -z "$dirty" ]]; then
|
|
BUILD="$VER" # formal release
|
|
else
|
|
BUILD="$VER-dev.$(date -u +%Y%m%dT%H%M%SZ).g$(git rev-parse --short HEAD 2>/dev/null || echo nogit)$dirty"
|
|
fi
|
|
else
|
|
BUILD="$VER-dev.$(date -u +%Y%m%dT%H%M%SZ)" # not a git checkout
|
|
fi
|
|
|
|
# stamp the version into the built copies only (source keeps the APP_VERSION placeholder)
|
|
for f in index.html mobile.html mobile-sessions.html pm_e-2.html; do
|
|
[[ -f "$DIST_DIR/$f" ]] || continue
|
|
tmp="$(mktemp)"
|
|
sed "s|const APP_VERSION = \"[^\"]*\";|const APP_VERSION = \"$BUILD\";|" "$DIST_DIR/$f" > "$tmp"
|
|
mv "$tmp" "$DIST_DIR/$f"
|
|
done
|
|
|
|
# Mirror dist/ -> web root, deleting anything that's no longer built (old pages, firmware, …)
|
|
rsync -a --delete "$DIST_DIR/" "$DEST_DIR/"
|
|
echo "deployed v$BUILD -> $DEST_DIR"
|
|
for f in index.html mobile.html mobile-sessions.html pm_e-2.html; do
|
|
echo " $f ($(stat -c '%s' "$DEST_DIR/$f") bytes)"
|
|
done
|
|
|
|
# Smoke test: Caddy serves on :8443 with tls internal; resolve the host
|
|
# to localhost so SNI matches the site block.
|
|
if command -v curl >/dev/null 2>&1; then
|
|
code=$(curl -sk --resolve metronome.varasys.io:8443:127.0.0.1 \
|
|
https://metronome.varasys.io:8443/ -o /dev/null -w '%{http_code}' || echo "??")
|
|
echo "smoke test: metronome.varasys.io -> HTTP $code"
|
|
fi
|