chore: add node22 bun base image and tune start
This commit is contained in:
parent
eebe1a717f
commit
43548ab4b8
3 changed files with 73 additions and 32 deletions
|
|
@ -17,48 +17,56 @@ echo "[start-web] NEXT_PUBLIC_CONVEX_URL=${NEXT_PUBLIC_CONVEX_URL:-}"
|
|||
|
||||
# Ensure system deps for native modules (best-effort, idempotent)
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
# Ensure curl/gnupg for NodeSource setup
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
apt-get update -y || true
|
||||
apt-get install -y --no-install-recommends curl ca-certificates gnupg || true
|
||||
fi
|
||||
|
||||
install_node() {
|
||||
local current_node_major=""
|
||||
if command -v node >/dev/null 2>&1; then
|
||||
current_node_major=$(node -v | sed -E 's/^v([0-9]+).*/\1/')
|
||||
if [ -n "$current_node_major" ] && [ "$current_node_major" -ge 20 ]; then
|
||||
return 0
|
||||
fi
|
||||
if [ "${SKIP_APT_BOOTSTRAP:-false}" = "true" ]; then
|
||||
echo "[start-web] SKIP_APT_BOOTSTRAP=true; skipping apt bootstrap"
|
||||
else
|
||||
# Ensure curl/gnupg for NodeSource setup
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
apt-get update -y || true
|
||||
apt-get install -y --no-install-recommends curl ca-certificates gnupg || true
|
||||
fi
|
||||
|
||||
echo "[start-web] installing Node.js 22.x via NodeSource"
|
||||
curl -fsSL https://deb.nodesource.com/setup_22.x | bash - || true
|
||||
apt-get update -y || true
|
||||
apt-get install -y --no-install-recommends nodejs || true
|
||||
}
|
||||
install_node() {
|
||||
local current_node_major=""
|
||||
if command -v node >/dev/null 2>&1; then
|
||||
current_node_major=$(node -v | sed -E 's/^v([0-9]+).*/\1/')
|
||||
if [ -n "$current_node_major" ] && [ "$current_node_major" -ge 20 ]; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Base toolchain for native modules
|
||||
apt-get update -y || true
|
||||
apt-get install -y --no-install-recommends build-essential python3 make pkg-config || true
|
||||
echo "[start-web] installing Node.js 22.x via NodeSource"
|
||||
curl -fsSL https://deb.nodesource.com/setup_22.x | bash - || true
|
||||
apt-get update -y || true
|
||||
apt-get install -y --no-install-recommends nodejs || true
|
||||
}
|
||||
|
||||
if ! command -v openssl >/dev/null 2>&1; then
|
||||
echo "[start-web] openssl not found; installing via apt-get (requires root)"
|
||||
# Base toolchain for native modules
|
||||
apt-get update -y || true
|
||||
apt-get install -y --no-install-recommends openssl ca-certificates || true
|
||||
apt-get install -y --no-install-recommends build-essential python3 make pkg-config || true
|
||||
|
||||
if ! command -v openssl >/dev/null 2>&1; then
|
||||
echo "[start-web] openssl not found; installing via apt-get (requires root)"
|
||||
apt-get update -y || true
|
||||
apt-get install -y --no-install-recommends openssl ca-certificates || true
|
||||
fi
|
||||
if ! command -v node >/dev/null 2>&1 && [ -x /usr/bin/nodejs ]; then
|
||||
ln -sf /usr/bin/nodejs /usr/bin/node || true
|
||||
fi
|
||||
install_node
|
||||
fi
|
||||
if ! command -v node >/dev/null 2>&1 && [ -x /usr/bin/nodejs ]; then
|
||||
ln -sf /usr/bin/nodejs /usr/bin/node || true
|
||||
fi
|
||||
install_node
|
||||
else
|
||||
echo "[start-web] apt-get unavailable; skipping system deps install" >&2
|
||||
fi
|
||||
|
||||
# Rebuild native better-sqlite3 bindings for the current Node version
|
||||
if command -v npm >/dev/null 2>&1; then
|
||||
echo "[start-web] rebuilding better-sqlite3 for current Node runtime"
|
||||
(npm rebuild better-sqlite3 >/dev/null 2>&1 && echo "[start-web] better-sqlite3 rebuilt") || echo "[start-web] rebuild skipped (using existing bindings)"
|
||||
if [ "${SKIP_SQLITE_REBUILD:-false}" = "true" ]; then
|
||||
echo "[start-web] skipping better-sqlite3 rebuild (SKIP_SQLITE_REBUILD=true)"
|
||||
else
|
||||
echo "[start-web] rebuilding better-sqlite3 for current Node runtime"
|
||||
(npm rebuild better-sqlite3 >/dev/null 2>&1 && echo "[start-web] better-sqlite3 rebuilt") || echo "[start-web] rebuild skipped (using existing bindings)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Bun keeps its store in node_modules/.bun by default; ensure it exists and is writable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue