Sam*_*het 6 bitbucket node.js npm bitbucket-pipelines angular
我正在尝试为我的 Angular 应用程序运行管道,但当涉及到“npm run build”部分时,它崩溃了,失败原因是“容器“Build”超出了内存限制。” 我尝试修改 yml 文件中的内存设置,例如添加“size 2x”并更改分配给 docker 的内存量。
位桶管道.yml:
image: node:14.17.0
options:
docker: true
size: 2x
pipelines:
custom:
prod-deployment:
- step:
name: Build angular app
caches:
- node
services:
- docker
size: 2x # Double resources available for this step.
script:
- mv .npmrc_config .npmrc
- npm install --unsafe-perm
- npm install -g @angular/cli@12.2.6
- free -m
- npm run dashboard:build
- wget "censored for security"
artifacts:
- dist/**
- step:
name: Deploy artifacts using SCP to PROD
deployment: production
size: 2x # Double resources available for this step.
script:
- pipe: atlassian/scp-deploy:1.1.0
variables:
USER: $USERNAME
SERVER: $SERVER
REMOTE_PATH: 'Censored for Security'
LOCAL_PATH: 'dist/*'
dev-deployment:
- step:
name: Build angular app
caches:
- node
services:
- docker
size: 2x # Double resources available for this step.
script:
- mv .npmrc_config .npmrc
- npm install --unsafe-perm
- npm install -g @angular/cli@12.2.6
- free -m
- npm run build
- wget 'Censored for Security'
artifacts:
- dist/**
- step:
name: Deploy artifacts using SCP to PROD
deployment: production
size: 2x # Double resources available for this step.
script:
- pipe: atlassian/scp-deploy:1.1.0
variables:
USER: $USERNAME
SERVER: $SERVER
REMOTE_PATH: 'Censored for Security'
LOCAL_PATH: 'dist/*'
definitions:
services:
docker:
memory: 4096
Run Code Online (Sandbox Code Playgroud)
控制台错误消息:
Killed
npm ERR! code ELIFECYCLE
npm ERR! errno 137
npm ERR! build: `node --max_old_space_size=6144 node_modules/@angular/cli/bin/ng build --configuration=calio && npm run `
npm ERR! Exit status 137
npm ERR!
npm ERR! Failed at the build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-10-14T08_40_46_012Z-debug.log
Run Code Online (Sandbox Code Playgroud)
除非确实需要,否则不要使用 docker 服务。它的内存资源(为您提供 4GB)将从该步骤的可用总资源中减去,因此这可能会导致您的内存短缺。
您可以使用更大的构建(大小:4x 或 8x),但仅限于自托管运行器。https://support.atlassian.com/bitbucket-cloud/docs/step-options/#Size
- step:
size: 4x # or 8x
runs-on:
- 'self.hosted'
- 'my.custom.label'
...
Run Code Online (Sandbox Code Playgroud)
请注意,您的跑步者将需要 16-32 GB 的实际内存。
npm run build
耗尽这么多内存就是出现错误的标志。在本地运行构建来调试可能是内存使用峰值的根本原因。例如看到这个类似的问题/sf/answers/5305310881/ 归档时间: |
|
查看次数: |
4792 次 |
最近记录: |