-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh.example
More file actions
55 lines (44 loc) · 2.27 KB
/
build.sh.example
File metadata and controls
55 lines (44 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
set -euo pipefail
# build.sh.example — copy to build.sh and customise for your environment.
#
# IMPORTANT: Always use this script instead of running `npm run build` directly.
#
# Why: `npm run build` nukes and recreates dist/ on every run. Any file placed
# directly in dist/ (rather than public/) is wiped. This script restores those
# files after the build so they are always present in production.
#
# Setup:
# cp build.sh.example build.sh
# chmod +x build.sh
# # Edit APP_DIR and VERSION_JSON_SRC to match your deployment paths
# # Add build.sh to .gitignore (already done) — it is machine-specific
# ── Configuration ────────────────────────────────────────────────────────────
# Absolute path to the app root on this machine
APP_DIR="/path/to/podda"
# Path to podda-app-version.json on this machine.
# This file is generated by your release pipeline and must survive each build.
# It is served at /podda-app-version.json and consumed by public/info.html.
VERSION_JSON_SRC="/path/to/podda-app-version.json"
# Systemd user-service name (leave blank to skip service restart)
SERVICE_NAME="podda"
# ── Build ─────────────────────────────────────────────────────────────────────
echo "=== Building Podda ==="
cd "$APP_DIR"
npm run build
# Restore generated files wiped by the Vite build
if [[ -f "$VERSION_JSON_SRC" ]]; then
cp "$VERSION_JSON_SRC" "$APP_DIR/dist/podda-app-version.json"
echo " Restored podda-app-version.json"
else
echo " WARNING: $VERSION_JSON_SRC not found — public/info.html will fail to load version info"
fi
# ── Restart service ───────────────────────────────────────────────────────────
if [[ -n "$SERVICE_NAME" ]]; then
echo "=== Restarting $SERVICE_NAME ==="
systemctl --user restart "$SERVICE_NAME"
echo "=== Done ==="
systemctl --user status "$SERVICE_NAME" --no-pager | head -5
else
echo "=== Build complete (no service restart configured) ==="
fi