fix: install node from official tarball in bootstrap

This commit is contained in:
hectorzhao
2026-07-07 15:04:19 +08:00
parent 9fee6fa81b
commit ac859d5607
2 changed files with 27 additions and 16 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ PROD_ADMIN_USERNAME=prod_admin
PROD_ADMIN_PASSWORD='change-me' PROD_ADMIN_PASSWORD='change-me'
``` ```
脚本会安装 Node.js、Go、PostgreSQL、Redis、MinIO、Nginx,创建 systemd 服务,执行 Prisma migrate,构建前端/API/Gateway,并创建平台管理员。Go 和 MinIO 下载会按服务器架构自动选择 `linux-amd64``linux-arm64` 脚本会安装 Node.js、Go、PostgreSQL、Redis、MinIO、Nginx,创建 systemd 服务,执行 Prisma migrate,构建前端/API/Gateway,并创建平台管理员。Node.js、Go 和 MinIO 下载会按服务器架构自动选择 x64/amd64 或 arm64。
## 后续发布 ## 后续发布
+26 -15
View File
@@ -29,35 +29,45 @@ install_packages() {
log "Installing OS packages" log "Installing OS packages"
if command -v apt-get >/dev/null 2>&1; then if command -v apt-get >/dev/null 2>&1; then
apt-get update apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates curl gnupg git nginx redis-server postgresql postgresql-contrib build-essential tar gzip openssl DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates curl gnupg git nginx redis-server postgresql postgresql-contrib build-essential tar gzip xz-utils openssl
if ! command -v node >/dev/null 2>&1 || [[ "$(node -v | sed 's/^v//' | cut -d. -f1)" -lt 22 ]]; then
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
fi
elif command -v dnf >/dev/null 2>&1; then elif command -v dnf >/dev/null 2>&1; then
dnf install -y ca-certificates curl git nginx redis postgresql-server postgresql-contrib gcc gcc-c++ make tar gzip openssl dnf install -y ca-certificates curl git nginx redis postgresql-server postgresql-contrib gcc gcc-c++ make tar gzip xz openssl
if [[ ! -d /var/lib/pgsql/data/base ]]; then if [[ ! -d /var/lib/pgsql/data/base ]]; then
postgresql-setup --initdb postgresql-setup --initdb
fi fi
if ! command -v node >/dev/null 2>&1 || [[ "$(node -v | sed 's/^v//' | cut -d. -f1)" -lt 22 ]]; then
curl -fsSL https://rpm.nodesource.com/setup_22.x | bash -
dnf install -y nodejs
fi
elif command -v yum >/dev/null 2>&1; then elif command -v yum >/dev/null 2>&1; then
yum install -y ca-certificates curl git nginx redis postgresql-server postgresql-contrib gcc gcc-c++ make tar gzip openssl yum install -y ca-certificates curl git nginx redis postgresql-server postgresql-contrib gcc gcc-c++ make tar gzip xz openssl
if [[ ! -d /var/lib/pgsql/data/base ]]; then if [[ ! -d /var/lib/pgsql/data/base ]]; then
postgresql-setup initdb postgresql-setup initdb
fi fi
if ! command -v node >/dev/null 2>&1 || [[ "$(node -v | sed 's/^v//' | cut -d. -f1)" -lt 22 ]]; then
curl -fsSL https://rpm.nodesource.com/setup_22.x | bash -
yum install -y nodejs
fi
else else
echo "Unsupported Linux distribution: apt-get/dnf/yum not found." >&2 echo "Unsupported Linux distribution: apt-get/dnf/yum not found." >&2
exit 1 exit 1
fi fi
} }
install_node() {
local version="${NODE_VERSION:-22.21.1}"
local arch
case "$(uname -m)" in
x86_64|amd64) arch="x64" ;;
aarch64|arm64) arch="arm64" ;;
*) echo "Unsupported Node.js architecture: $(uname -m)" >&2; exit 1 ;;
esac
if command -v node >/dev/null 2>&1 && [[ "$(node -v | sed 's/^v//' | cut -d. -f1)" -ge 22 ]]; then
return
fi
log "Installing Node.js ${version} for linux-${arch}"
curl -fL "https://nodejs.org/dist/v${version}/node-v${version}-linux-${arch}.tar.xz" -o /tmp/node.tar.xz
rm -rf /usr/local/lib/nodejs
mkdir -p /usr/local/lib/nodejs
tar -C /usr/local/lib/nodejs -xJf /tmp/node.tar.xz --strip-components=1
ln -sf /usr/local/lib/nodejs/bin/node /usr/local/bin/node
ln -sf /usr/local/lib/nodejs/bin/npm /usr/local/bin/npm
ln -sf /usr/local/lib/nodejs/bin/npx /usr/local/bin/npx
ln -sf /usr/local/lib/nodejs/bin/corepack /usr/local/bin/corepack
}
install_go() { install_go() {
local version="${GO_VERSION:-1.26.0}" local version="${GO_VERSION:-1.26.0}"
local arch local arch
@@ -240,6 +250,7 @@ run_deploy() {
} }
install_packages install_packages
install_node
install_go install_go
install_minio install_minio
start_infra start_infra