Skip to content

Segmentation fault with exit code 139 in supported node Docker image on ng build #26448

@paulThorsen

Description

@paulThorsen

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

v16

Description

Building a Docker image (using a base image of a supported node version) in Angular v17 always results in a segmentation fault exiting with code 139 on the npm run build step. I've read online the 139 signal points to a memory issue of some sort. I haven't been able to narrow down what is causing it.

The npm run build script simply translates to ng build. This works fine in other versions of Angular, but not v17. I'm able to successfully build the image if I omit the build step.

I'm using node:18.13.0 as my base image, but experienced the same issue on node:20.9.0. ng build runs fine locally, but always fails as described when building Docker images, either locally or in a CI/CD pipeline/action.

Minimal Reproduction

ng new test-docker-build
> SCSS
> n
> Add a very simple Dockerfile:

FROM node:18.13.0
WORKDIR /app
COPY . /app
RUN npm i
RUN npm run build

docker build -t test-docker-build .

Exception or Error

=> ERROR [5/5] RUN npm run build                                        1.1s
------                                                                        
 > [5/5] RUN npm run build:                                                   
0.968 
0.968 > test@0.0.0 build
0.968 > ng build
0.968 
1.052 Segmentation fault
------
Dockerfile:5
--------------------
   3 |     COPY . /app
   4 |     RUN npm i
   5 | >>> RUN npm run build
   6 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 139

Your Environment

Angular CLI: 17.0.0
Node: 18.13.0
Package Manager: npm 8.19.3
OS: darwin x64

Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1700.0 (cli-only)
@angular-devkit/core         17.0.0 (cli-only)
@angular-devkit/schematics   17.0.0 (cli-only)
@schematics/angular          17.0.0 (cli-only)

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions