From 94e92899f98c0b4b7bd5c0793610897355a5108f Mon Sep 17 00:00:00 2001 From: KM Koushik Date: Thu, 12 Nov 2026 05:52:30 +1100 Subject: [PATCH] fix(build): run the Railway build on Node 22.23.5 --- docker/nixpacks/install-node.sh | 31 +++++++++++++++++++++++++++++++ nixpacks.toml | 21 +++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 docker/nixpacks/install-node.sh create mode 100644 nixpacks.toml diff --git a/docker/nixpacks/install-node.sh b/docker/nixpacks/install-node.sh new file mode 100755 index 0000000..8355e4b --- /dev/null +++ b/docker/nixpacks/install-node.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# Installs a pinned official Node.js build into /app/.node for the Railway +# (Nixpacks) build and links it into /usr/bin. Nixpacks' own Node comes from a +# nixpkgs snapshot that lags Node security releases, so we pin the release. +# To update: change NODE_VERSION and both hashes from +# https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt +set -euo pipefail + +NODE_VERSION="22.23.5" +case "$(uname -m)" in + x86_64) ARCH="x64"; SHA256="cdeb8670a0c81f51b4dc4ac61919f9b1ad917b304bf8221eb939570663d240f8" ;; + aarch64 | arm64) ARCH="arm64"; SHA256="2babb9eb5264860d540849f4b064a6fbdebcdc323657d9d382ce23d313fd5e09" ;; + *) echo "install-node: unsupported architecture $(uname -m)" >&2; exit 1 ;; +esac + +TARBALL="node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" +DEST="/app/.node" +TMP="$(mktemp -d)" +trap 'rm -rf "$TMP"' EXIT + +curl -fsSL --retry 3 -o "$TMP/$TARBALL" "https://nodejs.org/dist/v${NODE_VERSION}/${TARBALL}" +echo "${SHA256} $TMP/$TARBALL" | sha256sum -c - + +rm -rf "$DEST" +mkdir -p "$DEST" +tar -xJf "$TMP/$TARBALL" -C "$DEST" --strip-components=1 + +# On the default PATH, so both build steps and the running server use it. +ln -sf "$DEST/bin/node" "$DEST/bin/npm" "$DEST/bin/npx" /usr/bin/ + +node -v diff --git a/nixpacks.toml b/nixpacks.toml new file mode 100644 index 0000000..d16871b --- /dev/null +++ b/nixpacks.toml @@ -0,0 +1,21 @@ +# Railway builds with Nixpacks. Its Node comes from a nixpkgs snapshot that lags +# Node security releases, so Node (and Nix's pnpm, which pulls in its own Node) +# isn't taken from Nix: docker/nixpacks/install-node.sh installs a pinned +# official release instead, used for both the build and the server. pnpm comes +# from corepack (packageManager in package.json). +# Update the version and hashes in that script with each Node security release. +[phases.setup] +nixPkgs = ["openssl"] + +[phases.node] +dependsOn = ["setup"] +cmds = ["bash docker/nixpacks/install-node.sh"] +# Only the script, so code changes don't redownload Node. +onlyIncludeFiles = ["docker/nixpacks/install-node.sh"] + +[phases.install] +dependsOn = ["node"] +cmds = [ + "npm install -g corepack@0.24.1 && ln -sf /app/.node/bin/corepack /usr/bin/corepack && corepack enable --install-directory /usr/bin", + "pnpm i --frozen-lockfile", +]