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:
<span>npm </span><span>WARN deprecated node-fetch-npm@2.0.4: This module is not used anymore, npm uses minipass-fetch for its fetch implementation now</span>
<span>/usr/local/bin/ng -> /usr/local/lib/node_modules/@angular/cli/bin/ng</span>
<span>npm</span><span> WARN </span><span>optional</span><span> SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.2 (node_modules/@angular/cli/node_modules/chokidar/node_modules/fsevents):</span>
<span>npm</span> <span>WARN</span><span> notsup</span><span> SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})</span>
<span>+ @angular/cli@7.3.9</span>
<span>added 295 packages from 186 contributors in 13.408s</span>
<span>Removing intermediate container f0bebb2a3cd2</span>
<span>---> ffae8ce12713</span>
<span>Step 8/14 : RUN npm run-script build-prod</span>
<span>---> Running in 08a2b0ce9bf6</span>
<span>> Angular-6@6.0.0 build-prod /app</span>
<span>> node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng build --base-href=/portal/ --prod</span>
<span>(node:20) [DEP0131] DeprecationWarning: The legacy HTTP parser is deprecated.</span>
<span>unexpected EOF</span>
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