ci(docker): 优化Node安装流程并添加nvm作为备选方案
Some checks failed
site-dist-deploy / build-and-deploy (push) Failing after 30s
Some checks failed
site-dist-deploy / build-and-deploy (push) Failing after 30s
This commit is contained in:
parent
c5062278a3
commit
be99c7acfa
@ -40,7 +40,6 @@ jobs:
|
|||||||
- name: Build dist in Node container
|
- name: Build dist in Node container
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
# ensure tools
|
|
||||||
install_pkgs() {
|
install_pkgs() {
|
||||||
PKGS="$*"
|
PKGS="$*"
|
||||||
if command -v apt-get >/dev/null 2>&1; then
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
@ -60,10 +59,7 @@ jobs:
|
|||||||
}
|
}
|
||||||
if ! command -v curl >/dev/null 2>&1; then install_pkgs curl ca-certificates; fi
|
if ! command -v curl >/dev/null 2>&1; then install_pkgs curl ca-certificates; fi
|
||||||
if ! command -v tar >/dev/null 2>&1; then install_pkgs tar; fi
|
if ! command -v tar >/dev/null 2>&1; then install_pkgs tar; fi
|
||||||
# xz is needed to extract Node tar.xz
|
|
||||||
if ! command -v xz >/dev/null 2>&1 && ! command -v unxz >/dev/null 2>&1; then install_pkgs xz-utils || install_pkgs xz; fi
|
if ! command -v xz >/dev/null 2>&1 && ! command -v unxz >/dev/null 2>&1; then install_pkgs xz-utils || install_pkgs xz; fi
|
||||||
|
|
||||||
# install Node by downloading official binary (avoid building from source)
|
|
||||||
if ! command -v node >/dev/null 2>&1; then
|
if ! command -v node >/dev/null 2>&1; then
|
||||||
NODE_VER="v20.19.6"
|
NODE_VER="v20.19.6"
|
||||||
ARCH="$(uname -m)"
|
ARCH="$(uname -m)"
|
||||||
@ -75,14 +71,24 @@ jobs:
|
|||||||
esac
|
esac
|
||||||
NODE_TARBALL="node-${NODE_VER}-${NODE_ARCH}.tar.xz"
|
NODE_TARBALL="node-${NODE_VER}-${NODE_ARCH}.tar.xz"
|
||||||
URL="https://nodejs.org/dist/${NODE_VER}/${NODE_TARBALL}"
|
URL="https://nodejs.org/dist/${NODE_VER}/${NODE_TARBALL}"
|
||||||
echo "Downloading Node from $URL"
|
|
||||||
curl -fsSL "$URL" -o "/tmp/${NODE_TARBALL}"
|
curl -fsSL "$URL" -o "/tmp/${NODE_TARBALL}"
|
||||||
mkdir -p "$HOME/node"
|
mkdir -p "$HOME/node"
|
||||||
tar -xJf "/tmp/${NODE_TARBALL}" -C "$HOME/node"
|
tar -xJf "/tmp/${NODE_TARBALL}" -C "$HOME/node"
|
||||||
NODE_DIR="$HOME/node/node-${NODE_VER}-${NODE_ARCH}"
|
NODE_DIR="$HOME/node/node-${NODE_VER}-${NODE_ARCH}"
|
||||||
export PATH="$NODE_DIR/bin:$PATH"
|
export PATH="$NODE_DIR/bin:$PATH"
|
||||||
fi
|
fi
|
||||||
node -v && npm -v
|
if ! node -v >/dev/null 2>&1; then
|
||||||
|
install_pkgs python3 make gcc g++ build-essential || true
|
||||||
|
export NVM_DIR="$HOME/.nvm"
|
||||||
|
if [ ! -d "$NVM_DIR" ]; then
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
|
||||||
|
fi
|
||||||
|
. "$NVM_DIR/nvm.sh"
|
||||||
|
nvm install 20
|
||||||
|
nvm use 20
|
||||||
|
fi
|
||||||
|
node -v
|
||||||
|
npm -v
|
||||||
npm ci
|
npm ci
|
||||||
echo "VITE_APP_BASE_URL=${VITE_APP_BASE_URL}" > .env.pord
|
echo "VITE_APP_BASE_URL=${VITE_APP_BASE_URL}" > .env.pord
|
||||||
npm run build:prod
|
npm run build:prod
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user