How to reduce npm installation time in multiple TeamCity builds?

Problem

  • We have a large number of build configurations in TeamCity that deal with npm installations of many of the same packages.
  • Since we need to apply clean checks to many of our assemblies (for example, for all PRs), the folder node_modulesin this assembly will never be reused
  • Installing npm in our assembly takes 4 minutes, which is about 40% of the time for this assembly.
  • On hundreds of assemblies per day for 10 agents, this number is worth reducing.

Question

What is the recommended way to centralize / reuse a folder node_modulesbetween assemblies given our stack?

Technological stack

  • Windows Server 2008 R2
  • Node LTS 4.x
  • TeamCity 9.x

What we tried

  • npm cache - , , , .
  • node_modules - ( ), , , gulp/grunt Windows. Womp womp.

,

  • node_modules : , , node_modules. node_modules .
  • NODE_PATH - , - , , node_modules, .
  • Powershell Move-Item back & : , , Move-Item, , , . .
+5
3

?

npm install Dockerfile, docker build

FROM node:12

WORKDIR /code

COPY ./package.json ./package-lock.json /code

RUN npm install # skiped when package.json/package-lock.json not changed.

ADD . /code

# do other things

Docker build (COPY/ADD/RUN) ( ) .

package.json/package-lock.json

docker build

COPY ./package.json ./package-lock.json /code

RUN npm install

npm install, .

0

Source: https://habr.com/ru/post/1663162/


All Articles