Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,464,990
Community Members
 
Community Events
176
Community Groups

Not able to do ng prod build for angular application

Hi,

I need some help in executing ng build --prod for my angular application in bitbucket. I have setup pipelines for deploying my angular application. But I am not able to do a build in prod mode. It always fails with "EOF" error shown below. The root cause seems to be due to lack memory. It seems this command  require large heap. PFB the error and my yml files. I am not sure how to achieve the prod build.

 

Error:

npm WARN deprecated node-fetch-npm@2.0.4: This module is not used anymore, npm uses minipass-fetch for its fetch implementation now
/usr/local/bin/ng -> /usr/local/lib/node_modules/@angular/cli/bin/ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.2 (node_modules/@angular/cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ @angular/cli@7.3.9
added 295 packages from 186 contributors in 13.408s
Removing intermediate container f0bebb2a3cd2
---> ffae8ce12713
Step 8/14 : RUN npm run-script build-prod
---> Running in 08a2b0ce9bf6
> Angular-6@6.0.0 build-prod /app
> node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng build --base-href=/portal/ --prod
(node:20) [DEP0131] DeprecationWarning: The legacy HTTP parser is deprecated.
unexpected EOF
Package.json
============
{
"name": "Angular-6",
"version": "6.0.0",
"license": "Apache",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"test-ci": "TEST_CI=true ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"build-prod": "node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng build --base-href=/portal/ --prod"
},
"private": true,
"dependencies": {
"@angular/animations": "~7.2.0",
"@angular/cdk": "~7.2.0",
"@angular/common": "~7.2.0",
..........
Bitbucket-pipeline.yml
image: atlassian/default-image:3
options:
docker: true
size: 2x
definitions:
steps:
- step: &deploy
name: Deploy to Dev
runs-on:
- 'self.hosted'
deployment: dev
size: 2x
trigger: manual
script:
- IMAGE=registry.digitalocean.com/gehi/$BITBUCKET_REPO_SLUG
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD registry.digitalocean.com
- docker build . --no-cache --pull --tag "${IMAGE}:$BITBUCKET_DEPLOYMENT_ENVIRONMENT"
- docker push "${IMAGE}:$BITBUCKET_DEPLOYMENT_ENVIRONMENT"
- pipe: atlassian/trigger-pipeline:5.0.0
variables:
BITBUCKET_USERNAME: $USER
BITBUCKET_APP_PASSWORD: $PASSWORD
REPOSITORY: 'myls-docker-deploy'
BRANCH_NAME: 'master'
WAIT: 'true'
PIPELINE_VARIABLES: >
[{
"key": "PIPELINE_ENVIRONMENT",
"value": "$BITBUCKET_DEPLOYMENT_ENVIRONMENT"
}]
services:
- docker
services:
docker:
memory: 4096
pipelines:
default:
- step:
name: Test Gradle
runs-on:
.......
Dockerfile ( steps referenced in docker build cmd above)

### STAGE 1: Build ###

FROM node:12.22.10-buster-slim as BUILDER

RUN apt-get update && apt-get install zip -y

# set working directory
WORKDIR /app

# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH

COPY . .

RUN npm install

RUN npm install -g @angular/cli@7.3.9

RUN export NODE_OPTIONS=--max-old-space-size=6144

RUN npm run-script build-prod

WORKDIR /app/dist

RUN zip -r /app/portal.war .

From registry.digitalocean.com/gehi/tomcat-8-0-53-alpine:custom

LABEL maintainer="priyadarshiniy@gehilaw.com"

COPY --from=BUILDER /app/portal.war /usr/local/tomcat/webapps/portal.war

EXPOSE 8080

1 answer

0 votes

Hi @Priyadarshiniy Rajendran and welcome to the community.

I see the 'self.hosted' label in your yml file, are you running this step in a Linux Docker Runner?

With the size: 2x option a step gets 8 GB of memory. The build container is given 1024 MB of the total memory, which covers your build process and some Pipelines overheads (agent container, logging, etc). The total memory for services in each pipeline step must not exceed the remaining memory, which is 7128 MB for 2x steps.

If the error occurs when the docker build command is running, and if the root cause is indeed a lack of memory, you can give more memory to the Docker service (in your definition it is 4096 MB), up to 7128 MB.

If this is not enough, with Runners, you can configure up to 32GB (8x) of memory to run your builds, provided that the server where you run the Runner has that memory available. Valid sizes for the size option are 1x, 2x, 4x, and 8x. The corresponding memory available is 4 GB, 8 GB, 16 GB, and 32 GB and the maximum memory you can assign to the service is 3072 MB, 7168 MB, 15360 MB, and 31744 MB respectively.

You may also need to adjust max-old-space-size depending on how much memory your build needs.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events