feat: add CentOS7 single executable build

This commit is contained in:
shiyue
2026-06-24 10:36:03 +08:00
parent a794607817
commit 67914ba10f
8 changed files with 365 additions and 26 deletions

View File

@@ -23,6 +23,34 @@ warn() {
printf '[cc-web pm2] WARNING: %s\n' "$*" >&2
}
node_upgrade_hint() {
cat <<'EOF'
可选处理方式:
# 已安装 nvm 时,使用当前 LTS 版本
nvm install --lts
nvm use --lts
node -v
# Ubuntu / Debian / WSL可固定安装 Node.js 22root 用户可去掉 sudo
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs
node -v
# RHEL / Rocky / AlmaLinux 8/9可固定安装 Node.js 22root 用户可去掉 sudo
curl -fsSL https://rpm.nodesource.com/setup_22.x | sudo bash -
sudo dnf install -y nodejs || sudo yum install -y nodejs
node -v
# CentOS 7 / glibc 2.17 不适合安装 NodeSource Node.js 22。
# 推荐在较新的构建机生成 Bun baseline 单文件发布包,再拷贝到 CentOS 7 直接运行:
npm install
npm run build:single-exe
# 拷贝 dist-exe/bun-linux-x64-baseline/ 到 CentOS 7 后:
cd dist-exe/bun-linux-x64-baseline
PORT=8002 CC_WEB_PASSWORD='请改成强密码' ./cc-web
EOF
}
ensure_command() {
local cmd="$1"
local hint="$2"
@@ -277,13 +305,17 @@ main() {
[[ -f "${ENTRY_PATH}" ]] || fail "找不到入口文件: ${ENTRY_PATH}"
ensure_command node "请先安装 Node.js 18 或更高版本。"
ensure_command node "请先安装 Node.js 18 或更高版本。
$(node_upgrade_hint)"
ensure_command npm "请先安装 npm。"
local node_major
node_major="$(node -p "Number(process.versions.node.split('.')[0])")"
if [[ "${node_major}" -lt 18 ]]; then
fail "Node.js 版本过低,当前为 $(node -v),要求 >= 18。"
fail "Node.js 版本过低,当前为 $(node -v),要求 >= 18。
$(node_upgrade_hint)"
fi
check_runtime_config