Skip to content
Merged
Prev Previous commit
Next Next commit
Optimize npm configurations in Dockerfiles and .npmrc for improved pe…
…rformance

- Updated .npmrc to enable progress and set loglevel to verbose.
- Increased fetch timeout and retry settings for better reliability.
- Enhanced Dockerfiles for both development and production environments with optimized npm configurations.
- Ensured global and project dependencies are installed with progress and verbose logging for better visibility during builds.
  • Loading branch information
RishabhJain2018 committed Sep 1, 2025
commit c5492cd2c02f5a290915e76fcc33a0470b29795a
11 changes: 6 additions & 5 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# npm configuration for EvalAI
fund=false
audit=false
progress=false
loglevel=error
progress=true
loglevel=verbose
save-exact=false
legacy-peer-deps=true
registry=https://registry.npmjs.org/
fetch-timeout=300000
fetch-retry-mintimeout=10000
fetch-retry-maxtimeout=60000
fetch-timeout=600000
fetch-retry-mintimeout=20000
fetch-retry-maxtimeout=120000
maxsockets=50
27 changes: 22 additions & 5 deletions docker/dev/nodejs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,44 @@
# Base stage with common dependencies
FROM node:18.19.0-bullseye AS base

# Set environment variables for better npm performance
ENV NODE_ENV=production
ENV NPM_CONFIG_LOGLEVEL=verbose
ENV NPM_CONFIG_PROGRESS=true
ENV NPM_CONFIG_FETCH_TIMEOUT=600000
ENV NPM_CONFIG_FETCH_RETRY_MINTIMEOUT=20000
ENV NPM_CONFIG_FETCH_RETRY_MAXTIMEOUT=120000

# Install Python2, symlink, and C++ build tools for node-gyp/node-sass
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python2 \
python-is-python2 \
make \
g++ && \
g++ \
curl && \
rm -rf /var/lib/apt/lists/*

WORKDIR /code

# Copy package files first for better caching
COPY package.json bower.json gulpfile.js .eslintrc karma.conf.js .npmrc ./

# Install global dependencies first with optimizations
RUN npm install -g bower gulp gulp-cli karma-cli qs --no-audit --no-fund && \
# Configure npm with better settings for Docker builds
RUN npm config set fetch-timeout 600000 && \
npm config set fetch-retry-mintimeout 20000 && \
npm config set fetch-retry-maxtimeout 120000 && \
npm config set progress true && \
npm config set loglevel verbose && \
npm config set maxsockets 50

# Install global dependencies first with optimizations and progress
RUN npm install -g bower gulp gulp-cli karma-cli qs --no-audit --no-fund --progress --verbose && \
npm link gulp && \
npm cache clean -f

# Install project dependencies with optimizations
RUN npm install --only=production --no-audit --no-fund --prefer-offline && \
# Install project dependencies with optimizations and progress
RUN npm install --only=production --no-audit --no-fund --prefer-offline --progress --verbose && \
bower install --allow-root

# AMD64-specific stage
Expand Down
13 changes: 10 additions & 3 deletions docker/prod/nodejs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ WORKDIR /code
# Copy package files first for better caching
COPY package.json bower.json gulpfile.js .eslintrc karma.conf.js .npmrc ./

# Configure npm with better settings for Docker builds
RUN npm config set fetch-timeout 600000 && \
npm config set fetch-retry-mintimeout 20000 && \
npm config set fetch-retry-maxtimeout 120000 && \
npm config set progress true && \
npm config set loglevel verbose

# Install global dependencies
RUN npm install -g bower gulp gulp-cli qs && \
npm install phantomjs-prebuilt && \
RUN npm install -g bower gulp gulp-cli qs --progress && \
npm install phantomjs-prebuilt --progress && \
npm link gulp && \
npm cache clean -f

# Install project dependencies with optimizations
RUN npm install --only=production --no-audit --no-fund --prefer-offline && \
RUN npm install --only=production --no-audit --no-fund --prefer-offline --progress && \
bower install --allow-root

# Copy frontend source
Expand Down