mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 09:47:22 +01:00
scripts/deploy-local.sh copies runtime assets into .next/standalone and restarts a local systemd service. Both are wrong on Vercel (no standalone output by default, no systemd), and any failure inside the script surfaces as the confusing "Command npm run build exited with 1" on Vercel without hinting at the postbuild as the culprit. Bail at the top when VERCEL or CI is set so the build proceeds with just next build, the way Vercel expects. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
52 lines
2.5 KiB
Bash
Executable File
52 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# deploy-local.sh — runs automatically as the npm postbuild hook.
|
|
#
|
|
# Copies runtime assets into .next/standalone/ (required for the production
|
|
# server to serve CSS, JS chunks, public files, and markdown content) then restarts
|
|
# the fleetcrown-app systemd service if it is installed on this machine.
|
|
# Legacy cockpit-app service name is supported as a fallback for transitional installs.
|
|
#
|
|
# Skips silently in CI or on machines where the service is not installed, so
|
|
# running `npm run build` on Vercel / GitHub Actions stays clean.
|
|
|
|
set -euo pipefail
|
|
|
|
# Vercel and other hosted CI builds must not run the local standalone-copy
|
|
# + systemd restart path — Vercel ships its own runtime + has no systemd, so
|
|
# any failure here surfaces as a misleading "Command npm run build exited
|
|
# with 1". Skip cleanly when a known hosted-CI marker is set.
|
|
if [ -n "${VERCEL:-}" ] || [ -n "${CI:-}" ]; then
|
|
echo "→ deploy: hosted CI detected (VERCEL/CI set) — skipping local standalone+systemd path"
|
|
exit 0
|
|
fi
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
STANDALONE="$PROJECT_DIR/.next/standalone"
|
|
|
|
if [ ! -d "$STANDALONE" ]; then
|
|
# Standalone output not present (e.g. output: "export" override or CI).
|
|
exit 0
|
|
fi
|
|
|
|
# ── Copy runtime assets ───────────────────────────────────────────────────────
|
|
# Next standalone tracing does not include client/static assets or markdown
|
|
# loaded from process.cwd() by server-rendered content routes.
|
|
rm -rf "$STANDALONE/.next/static" "$STANDALONE/public" "$STANDALONE/content"
|
|
cp -r "$PROJECT_DIR/.next/static" "$STANDALONE/.next/static"
|
|
cp -r "$PROJECT_DIR/public" "$STANDALONE/public"
|
|
cp -r "$PROJECT_DIR/content" "$STANDALONE/content"
|
|
echo "→ deploy: runtime assets copied to standalone"
|
|
|
|
# ── Restart systemd service (local machine only) ──────────────────────────────
|
|
# Prefer the canonical fleetcrown-app service; fall back to legacy cockpit-app
|
|
# for machines still running the pre-rename install.
|
|
for SERVICE in fleetcrown-app cockpit-app; do
|
|
SERVICE_FILE="$HOME/.config/systemd/user/${SERVICE}.service"
|
|
if [ -f "$SERVICE_FILE" ] && systemctl --user is-enabled --quiet "$SERVICE" 2>/dev/null; then
|
|
systemctl --user restart "$SERVICE"
|
|
echo "→ deploy: ${SERVICE} service restarted"
|
|
break
|
|
fi
|
|
done
|