ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
harden(installer): raise Node floor to 20.19+/22.12+ for vite 8 + fix update.sh @BIND_HOST@
Juan Denisca354e228a17
diff --git a/.github/workflows/extensions-ci.yml b/.github/workflows/extensions-ci.ymlindex 6ae5e700..2b468270 100644--- a/.github/workflows/extensions-ci.yml+++ b/.github/workflows/extensions-ci.yml@@ -31,6 +31,6 @@ jobs:- uses: actions/checkout@v4- uses: actions/setup-node@v4with:- node-version: '20'+ node-version: '22'- name: Check builtin-extension frontends are in syncrun: node scripts/sync-builtin-frontends.mjs --checkdiff --git a/.github/workflows/release-smoke.yml b/.github/workflows/release-smoke.ymlindex f243d7e7..b2a35cfb 100644--- a/.github/workflows/release-smoke.yml+++ b/.github/workflows/release-smoke.yml@@ -36,7 +36,7 @@ jobs:- name: Set up Node.jsuses: actions/setup-node@v4with:- node-version: '20'+ node-version: '22'- name: Install build dependenciesrun: |diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 5a124cae..13a5d4e8 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -93,7 +93,7 @@ jobs:- name: Set up Node.jsuses: actions/setup-node@v4with:- node-version: '20'+ node-version: '22'- name: Install build dependenciesrun: |diff --git a/.github/workflows/scripts-nightly.yml b/.github/workflows/scripts-nightly.ymlindex 12168750..9a752bc1 100644--- a/.github/workflows/scripts-nightly.yml+++ b/.github/workflows/scripts-nightly.yml@@ -41,7 +41,7 @@ jobs:- name: Set up Node.jsuses: actions/setup-node@v4with:- node-version: '20'+ node-version: '22'- name: Install build dependenciesrun: |diff --git a/Dockerfile b/Dockerfileindex 02436ab5..653b4a86 100644--- a/Dockerfile+++ b/Dockerfile@@ -16,7 +16,7 @@# --platform=$BUILDPLATFORM: dist/ is static JS/CSS (arch-independent), so this# stage always runs natively on the build machine — never under QEMU, where an# emulated `npm ci` takes 20-40 min (or hangs) during multi-arch release builds.-FROM --platform=$BUILDPLATFORM node:20-alpine AS frontend-builder+FROM --platform=$BUILDPLATFORM node:22-alpine AS frontend-builderWORKDIR /app/frontenddiff --git a/install.sh b/install.shindex 8a8a1607..394adb8a 100644--- a/install.sh+++ b/install.sh@@ -677,10 +677,20 @@ ensure_compose_plugin() {# it, so we install the distro package first and only pipe NodeSource into bash# when the distro can't deliver a new-enough Node + npm.node_major() { node --version 2>/dev/null | sed -E 's/^v([0-9]+).*/\1/'; }+# Vite 8 / rolldown (the frontend bundler) require Node ^20.19.0 || >=22.12.0.+# On anything older, npm silently skips rolldown's native binary and+# `npm run build` dies with a cryptic MODULE_NOT_FOUND — so gate on the real floor.node_ready() {command -v node &>/dev/null && command -v npm &>/dev/null || return 1- local m; m="$(node_major)"- [ -n "$m" ] && [ "$m" -ge 18 ] 2>/dev/null+ local v M m+ v="$(node --version 2>/dev/null | sed -E 's/^v//')"+ M="${v%%.*}"; m="${v#*.}"; m="${m%%.*}"+ case "$M" in ''|*[!0-9]*) return 1;; esac+ case "$m" in ''|*[!0-9]*) return 1;; esac+ if [ "$M" -eq 20 ] && [ "$m" -ge 19 ]; then return 0; fi+ if [ "$M" -eq 22 ] && [ "$m" -ge 12 ]; then return 0; fi+ if [ "$M" -ge 23 ]; then return 0; fi+ return 1}provision_node() {@@ -702,18 +712,18 @@ provision_node() {command -v npm &>/dev/null || pkg_add npm 2>/dev/null || trueif ! node_ready; then- warn "Distro Node.js is missing or older than 18 — falling back to NodeSource 20."+ warn "Distro Node.js is missing or too old to build the frontend (need 20.19+ or 22.12+) — falling back to NodeSource 22 LTS."if [ "$OS_FAMILY" = "debian" ]; then- curl -fsSL https://deb.nodesource.com/setup_20.x | bash - >/dev/null 2>&1 || true+ curl -fsSL https://deb.nodesource.com/setup_22.x | bash - >/dev/null 2>&1 || trueelse- curl -fsSL https://rpm.nodesource.com/setup_20.x | bash - >/dev/null 2>&1 || true+ curl -fsSL https://rpm.nodesource.com/setup_22.x | bash - >/dev/null 2>&1 || truefipkg_add nodejs || truefinode_ready || \- halt "Node.js 18+ (with npm) is required but could not be installed. Install Node 20 LTS and re-run."- good "Node.js $(node --version) installed."+ halt "Node.js 20.19+ or 22.12+ (with npm) is required to build the frontend but could not be installed. Install Node 22 LTS and re-run."+ good "Node.js $(node --version) ready."}# ---------------------------------------------------------------------------diff --git a/scripts/test/test_update.sh b/scripts/test/test_update.shindex 93078698..9556556c 100644--- a/scripts/test/test_update.sh+++ b/scripts/test/test_update.sh@@ -986,6 +986,71 @@ elsebad "quarantine_carried_plugins failed to move a carried plugin aside (or false-positived)"fi+# --------------------------------------------------------------------------+# T32 — _node_build_ok gates on vite 8's Node floor (^20.19.0 || >=22.12.0) so a+# source-mode update on an old-Node box fails fast with an actionable message+# instead of a cryptic rolldown MODULE_NOT_FOUND mid-build (plan 47 / vite 8).+# --------------------------------------------------------------------------+t="$WORK/t32"; mkdir -p "$t/bin"+_mk_node_stub() { printf '#!/usr/bin/env bash\n[ "$1" = "--version" ] && echo "v%s"\nexit 0\n' "$1" > "$t/bin/node"; chmod +x "$t/bin/node"; }+node_gate_ok=1+for v in 20.19.0 22.12.0 24.1.0; do+ _mk_node_stub "$v"+ ( set -Eeuo pipefail; PATH="$t/bin:$PATH"; _node_build_ok ) || node_gate_ok=0+done+for v in 18.20.0 20.17.0 20.18.9 21.7.0 22.11.0; do+ _mk_node_stub "$v"+ ( set -Eeuo pipefail; PATH="$t/bin:$PATH"; _node_build_ok ) && node_gate_ok=0+done+if [ "$node_gate_ok" = 1 ]; then+ ok "_node_build_ok accepts 20.19+/22.12+ and rejects older (incl. 21.x, 22.11)"+else+ bad "_node_build_ok mis-gated a Node version against the vite 8 floor"+fi++# --------------------------------------------------------------------------+# T33 — build_frontend_bundle refuses (returns 1, never touches npm) on a+# too-old Node, so the caller rolls back instead of a half-built bundle.+# --------------------------------------------------------------------------+t="$WORK/t33"; mkdir -p "$t/bin" "$t/tree/frontend"+printf '#!/usr/bin/env bash\n[ "$1" = "--version" ] && echo "v20.17.0"\nexit 0\n' > "$t/bin/node"; chmod +x "$t/bin/node"+printf '#!/usr/bin/env bash\necho ran >> "%s/npmlog"\nexit 0\n' "$t" > "$t/bin/npm"; chmod +x "$t/bin/npm"+if (+ set -Eeuo pipefail+ PATH="$t/bin:$PATH"+ ! build_frontend_bundle "$t/tree"+) >/dev/null 2>&1 && [ ! -e "$t/npmlog" ]; then+ ok "build_frontend_bundle refuses on too-old Node without touching npm"+else+ bad "build_frontend_bundle ran npm (or returned 0) on a too-old Node"+fi++# --------------------------------------------------------------------------+# T34 — refresh_config renders the systemd unit with @BIND_HOST@ substituted+# (loopback), not left as a literal placeholder that would break gunicorn's bind+# after an update (parity with install.sh; the gap the operator caught).+# --------------------------------------------------------------------------+t="$WORK/t34"+mkdir -p "$t/nginx/sites-available" "$t/nginx/sites-enabled" \+ "$t/target/nginx/sites-available" "$t/target/templates" "$t/sysd"+printf 'http {\n}\n' > "$t/nginx/nginx.conf"+printf 'server { listen 80; }\n' > "$t/target/nginx/sites-available/serverkit-insecure.conf"+printf 'ExecStart=gunicorn -b @BIND_HOST@:@PORT@ run:app\n' \+ > "$t/target/templates/serverkit-backend.service.in"+(+ set -Eeuo pipefail+ NGINX_DIR="$t/nginx"; LETSENCRYPT_DIR="$t/le"; SYSTEMD_DIR="$t/sysd"; CONFIG_DIR="$t/cfg"+ INSTALL_DIR="$t/opt"; VENV_DIR="$t/venv"; LOG_DIR="$t/log"; DRY_RUN=0+ refresh_config "$t/target"+) >/dev/null 2>&1+if [ -f "$t/sysd/serverkit.service" ] \+ && ! grep -q '@BIND_HOST@' "$t/sysd/serverkit.service" \+ && grep -q '127.0.0.1:' "$t/sysd/serverkit.service"; then+ ok "refresh_config substitutes @BIND_HOST@ in the systemd unit (loopback bind)"+else+ bad "refresh_config left a literal @BIND_HOST@ (gunicorn would fail to bind after update)"+fi+# --------------------------------------------------------------------------printf '\n%d passed, %d failed, %d skipped\n\n' "$PASS" "$FAIL" "$SKIP"[ "$FAIL" -eq 0 ]diff --git a/scripts/update.sh b/scripts/update.shindex c68aa227..666a5abf 100644--- a/scripts/update.sh+++ b/scripts/update.sh@@ -857,10 +857,31 @@ preserve_installed_plugins() {return 0}+# Vite 8 / rolldown (the frontend bundler) require Node ^20.19.0 || >=22.12.0.+# Returns 1 (no output) on an absent/too-old Node so callers can warn+rollback or+# halt with an actionable message, instead of npm silently skipping rolldown's+# native binary and `npm run build` dying with a cryptic MODULE_NOT_FOUND.+_node_build_ok() {+ command -v node >/dev/null 2>&1 || return 1+ local v M m+ v="$(node --version 2>/dev/null | sed -E 's/^v//')"+ M="${v%%.*}"; m="${v#*.}"; m="${m%%.*}"+ case "$M" in ''|*[!0-9]*) return 1;; esac+ case "$m" in ''|*[!0-9]*) return 1;; esac+ if [ "$M" -eq 20 ] && [ "$m" -ge 19 ]; then return 0; fi+ if [ "$M" -eq 22 ] && [ "$m" -ge 12 ]; then return 0; fi+ if [ "$M" -ge 23 ]; then return 0; fi+ return 1+}+# Build the SPA bundle in a target tree. Pass "reuse" as $2 to skip npm ci# (node_modules already intact from a just-failed build). Subshell so the cd# cannot leak into the main shell.build_frontend_bundle() {+ if ! _node_build_ok; then+ warn "Node.js $(node --version 2>/dev/null || echo 'not found') is too old to build the frontend — vite 8 needs 20.19+ or 22.12+. Upgrade Node (e.g. NodeSource 22 LTS) and re-run the update."+ return 1+ fi( cd "$1/frontend" && \{ [ "${2:-}" = "reuse" ] || npm ci --prefer-offline 2>&1 | tail -3; } && \NODE_OPTIONS="--max-old-space-size=1024" npm run build 2>&1 | tail -5 )@@ -1109,10 +1130,16 @@ EOF# so blue/green switches need no re-render). Fall back to a plain unit if an# older tree still ships one.local svc_template="$target/templates/serverkit-backend.service.in"+ # Bind the API to loopback by default — host nginx fronts it on :80/:443, so+ # the raw gunicorn port must not be world-reachable. Mirror install.sh so an+ # update re-renders @BIND_HOST@ instead of leaving the literal placeholder+ # (which would make gunicorn fail to bind). Override with SERVERKIT_BIND_HOST.+ local bind_host="${SERVERKIT_BIND_HOST:-127.0.0.1}"if [ -f "$svc_template" ]; thensed -e "s|@SERVERKIT_DIR@|$INSTALL_DIR|g" \-e "s|@SERVERKIT_VENV_DIR@|$VENV_DIR|g" \-e "s|@PORT@|5000|g" \+ -e "s|@BIND_HOST@|$bind_host|g" \-e "s|@USER@|root|g" \-e "s|@LOG_DIR@|$LOG_DIR|g" \"$svc_template" > "$SYSTEMD_DIR/serverkit.service"@@ -1538,6 +1565,7 @@ update_docker_compose() {if [ "$DRY_RUN" = "1" ]; theninfo "[dry-run] would npm ci + npm run build in frontend/"elif command -v npm &>/dev/null; then+ _node_build_ok || halt "Node.js $(node --version 2>/dev/null || echo 'not found') is too old to build the frontend — vite 8 needs 20.19+ or 22.12+. Upgrade Node (e.g. NodeSource 22 LTS) and re-run."( cd "$INSTALL_DIR/frontend" && npm ci 2>&1 | tail -n3 && \NODE_OPTIONS="--max-old-space-size=1024" npm run build 2>&1 | tail -n5 ) \|| halt "Frontend build failed"