Merge pull request #2788 from KNY00/feature/npm-retry-options

Add retry configuration options for npm
This commit is contained in:
Shao Yu-Lung (Allen) 2020-12-17 16:30:48 +08:00 committed by GitHub
commit a2622323cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 0 deletions

View File

@ -91,6 +91,10 @@ services:
- NVM_NODEJS_ORG_MIRROR=${WORKSPACE_NVM_NODEJS_ORG_MIRROR}
- INSTALL_NODE=${WORKSPACE_INSTALL_NODE}
- NPM_REGISTRY=${WORKSPACE_NPM_REGISTRY}
- NPM_FETCH_RETRIES=${WORKSPACE_NPM_FETCH_RETRIES}
- NPM_FETCH_RETRY_FACTOR=${WORKSPACE_NPM_FETCH_RETRY_FACTOR}
- NPM_FETCH_RETRY_MINTIMEOUT=${WORKSPACE_NPM_FETCH_RETRY_MINTIMEOUT}
- NPM_FETCH_RETRY_MAXTIMEOUT=${WORKSPACE_NPM_FETCH_RETRY_MAXTIMEOUT}
- INSTALL_PNPM=${WORKSPACE_INSTALL_PNPM}
- INSTALL_YARN=${WORKSPACE_INSTALL_YARN}
- INSTALL_NPM_GULP=${WORKSPACE_INSTALL_NPM_GULP}

View File

@ -104,6 +104,10 @@ WORKSPACE_NVM_NODEJS_ORG_MIRROR=
WORKSPACE_INSTALL_NODE=true
WORKSPACE_NODE_VERSION=node
WORKSPACE_NPM_REGISTRY=
WORKSPACE_NPM_FETCH_RETRIES=2
WORKSPACE_NPM_FETCH_RETRY_FACTOR=10
WORKSPACE_NPM_FETCH_RETRY_MINTIMEOUT=10000
WORKSPACE_NPM_FETCH_RETRY_MAXTIMEOUT=60000
WORKSPACE_INSTALL_PNPM=false
WORKSPACE_INSTALL_YARN=true
WORKSPACE_YARN_VERSION=latest

View File

@ -690,6 +690,14 @@ ARG INSTALL_NPM_VUE_CLI=false
ARG INSTALL_NPM_ANGULAR_CLI=false
ARG NPM_REGISTRY
ENV NPM_REGISTRY ${NPM_REGISTRY}
ARG NPM_FETCH_RETRIES
ENV NPM_FETCH_RETRIES ${NPM_FETCH_RETRIES}
ARG NPM_FETCH_RETRY_FACTOR
ENV NPM_FETCH_RETRY_FACTOR ${NPM_FETCH_RETRY_FACTOR}
ARG NPM_FETCH_RETRY_MINTIMEOUT
ENV NPM_FETCH_RETRY_MINTIMEOUT ${NPM_FETCH_RETRY_MINTIMEOUT}
ARG NPM_FETCH_RETRY_MAXTIMEOUT
ENV NPM_FETCH_RETRY_MAXTIMEOUT ${NPM_FETCH_RETRY_MAXTIMEOUT}
ENV NVM_DIR /home/laradock/.nvm
ARG NVM_NODEJS_ORG_MIRROR
ENV NVM_NODEJS_ORG_MIRROR ${NVM_NODEJS_ORG_MIRROR}
@ -702,6 +710,10 @@ RUN if [ ${INSTALL_NODE} = true ]; then \
&& nvm install ${NODE_VERSION} \
&& nvm use ${NODE_VERSION} \
&& nvm alias ${NODE_VERSION} \
&& npm config set fetch-retries ${NPM_FETCH_RETRIES} \
&& npm config set fetch-retry-factor ${NPM_FETCH_RETRY_FACTOR} \
&& npm config set fetch-retry-mintimeout ${NPM_FETCH_RETRY_MINTIMEOUT} \
&& npm config set fetch-retry-maxtimeout ${NPM_FETCH_RETRY_MAXTIMEOUT} \
&& if [ ${NPM_REGISTRY} ]; then \
npm config set registry ${NPM_REGISTRY} \
;fi \