mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-06 00:38:29 +01:00
`npm run build` alone left .next/standalone/ with stale CSS/JS chunks, causing the production server to serve 404s until `install-app` was run manually. The new postbuild hook runs deploy-local.sh automatically after every build: copies .next/static and public/ into standalone, then conditionally restarts the cockpit-app systemd service if installed. No-ops cleanly on CI (no standalone dir) and on machines without the service (systemctl check skipped). install-app is preserved for first-time setup. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
1.7 KiB
Bash
Executable File
38 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# deploy-local.sh — runs automatically as the npm postbuild hook.
|
|
#
|
|
# Copies the compiled static assets into .next/standalone/ (required for the
|
|
# production server to serve CSS, JS chunks, and public files) then restarts
|
|
# the cockpit-app systemd service if it is installed on this machine.
|
|
#
|
|
# 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
|
|
|
|
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 static assets ────────────────────────────────────────────────────────
|
|
# next build does not copy .next/static or public/ into standalone/.
|
|
# Without this, the production server serves 404 for all CSS/JS chunks.
|
|
rm -rf "$STANDALONE/.next/static" "$STANDALONE/public"
|
|
cp -r "$PROJECT_DIR/.next/static" "$STANDALONE/.next/static"
|
|
cp -r "$PROJECT_DIR/public" "$STANDALONE/public"
|
|
echo "→ deploy: static assets copied to standalone"
|
|
|
|
# ── Restart systemd service (local machine only) ──────────────────────────────
|
|
SERVICE="cockpit-app"
|
|
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: cockpit-app service restarted"
|
|
fi
|