docker 容器中 aurelia 项目的 Npm 安装在 jenkins 构建服务器上获得 stuck/hangs
Npm install of aurelia project in docker container gets stuck/hangs on jenkins build server
问题
我的大部分 Jenkins 构建都卡在了 npm install
。该问题在本地不可重现,因此很难缩小范围。 构建服务器会一直挂在“随机”包上,直到您手动停止它。
16:33:55 [0m[91mnpm http fetch GET 200 https://registry.npmjs.org/ws/-/ws-6.2.1.tgz 737ms
分析
前端由 Aurelia 开发,是 Docker 管理的 monorepo 的一部分。这是我唯一使用 Aurelia CLI 的项目,所以我认为我可以在那里找到问题 - 但没有任何结果。
我已经尝试通过执行 npm install --verbose
来分析问题,但没有获得任何额外的有价值信息。这不是导致问题的特定软件包,也不是明显的超时。
# Dockerfile
FROM node:12.13.0 as builder
WORKDIR /web
COPY web .
RUN pwd
RUN npm install --verbose
RUN npm run build
FROM nginx:mainline-alpine
COPY --from=builder /web/dist /usr/share/nginx/html
COPY html/index.html /usr/share/nginx/html/index2.html
COPY nginx.conf /etc/nginx/nginx.conf
查了半天,发现新引入的npm ci command and used it instead of npm install解决了问题。不幸的是,安装一个干净状态的项目是个好主意 ;-)
This command is similar to npm-install, except it’s meant to be used
in automated environments such as test platforms, continuous
integration, and deployment – or any situation where you want to make
sure you’re doing a clean install of your dependencies. It can be
significantly faster than a regular npm install by skipping certain
user-oriented features. It is also more strict than a regular install,
which can help catch errors or inconsistencies caused by the
incrementally-installed local environments of most npm users.
问题
我的大部分 Jenkins 构建都卡在了 npm install
。该问题在本地不可重现,因此很难缩小范围。 构建服务器会一直挂在“随机”包上,直到您手动停止它。
16:33:55 [0m[91mnpm http fetch GET 200 https://registry.npmjs.org/ws/-/ws-6.2.1.tgz 737ms
分析
前端由 Aurelia 开发,是 Docker 管理的 monorepo 的一部分。这是我唯一使用 Aurelia CLI 的项目,所以我认为我可以在那里找到问题 - 但没有任何结果。
我已经尝试通过执行 npm install --verbose
来分析问题,但没有获得任何额外的有价值信息。这不是导致问题的特定软件包,也不是明显的超时。
# Dockerfile
FROM node:12.13.0 as builder
WORKDIR /web
COPY web .
RUN pwd
RUN npm install --verbose
RUN npm run build
FROM nginx:mainline-alpine
COPY --from=builder /web/dist /usr/share/nginx/html
COPY html/index.html /usr/share/nginx/html/index2.html
COPY nginx.conf /etc/nginx/nginx.conf
查了半天,发现新引入的npm ci command and used it instead of npm install解决了问题。不幸的是,安装一个干净状态的项目是个好主意 ;-)
This command is similar to npm-install, except it’s meant to be used in automated environments such as test platforms, continuous integration, and deployment – or any situation where you want to make sure you’re doing a clean install of your dependencies. It can be significantly faster than a regular npm install by skipping certain user-oriented features. It is also more strict than a regular install, which can help catch errors or inconsistencies caused by the incrementally-installed local environments of most npm users.