diff --git a/scripts/deploy/bin/deploy.sh b/scripts/deploy/bin/deploy.sh index d8ed9ecb..1339dd26 100644 --- a/scripts/deploy/bin/deploy.sh +++ b/scripts/deploy/bin/deploy.sh @@ -22,6 +22,11 @@ source "$CONFIG_FILE" : "${RUN_SECURITY_CHECKS:=true}" : "${RUN_LAUNCH_GATE:=true}" : "${RESTART_SERVICES:=true}" +: "${NPM_REGISTRY:=https://registry.npmjs.org/}" +: "${NPM_FETCH_RETRIES:=5}" +: "${NPM_FETCH_RETRY_MINTIMEOUT:=20000}" +: "${NPM_FETCH_RETRY_MAXTIMEOUT:=120000}" +: "${NPM_FETCH_TIMEOUT:=300000}" LOCK_FILE="${LOCK_FILE:-/tmp/tiku-saas-deploy.lock}" mkdir -p "$APP_ROOT" "$WWW_ROOT/student" "$WWW_ROOT/tenant-admin" "$WWW_ROOT/platform-admin" @@ -94,7 +99,12 @@ CURRENT_SHA="$(git rev-parse --short=12 HEAD)" log "Deploying commit $CURRENT_SHA" log "Installing dependencies with npm ci..." -npm ci +npm ci \ + --registry="$NPM_REGISTRY" \ + --fetch-retries="$NPM_FETCH_RETRIES" \ + --fetch-retry-mintimeout="$NPM_FETCH_RETRY_MINTIMEOUT" \ + --fetch-retry-maxtimeout="$NPM_FETCH_RETRY_MAXTIMEOUT" \ + --fetch-timeout="$NPM_FETCH_TIMEOUT" if [[ "$RUN_SECURITY_CHECKS" == "true" ]]; then log "Running repository security scan..." diff --git a/scripts/deploy/env/deploy.env.example b/scripts/deploy/env/deploy.env.example index 302e0497..c876d95a 100644 --- a/scripts/deploy/env/deploy.env.example +++ b/scripts/deploy/env/deploy.env.example @@ -16,3 +16,10 @@ RUNTIME_CONFIG_DIR=/etc/tiku-saas/runtime-config RUN_SECURITY_CHECKS=true RUN_LAUNCH_GATE=true RESTART_SERVICES=true + +# Use https://registry.npmmirror.com on mainland China servers if npmjs times out. +NPM_REGISTRY=https://registry.npmjs.org/ +NPM_FETCH_RETRIES=5 +NPM_FETCH_RETRY_MINTIMEOUT=20000 +NPM_FETCH_RETRY_MAXTIMEOUT=120000 +NPM_FETCH_TIMEOUT=300000