Docker: ng build: Segmentation fault error

Discussão em 'Angular' iniciado por Palmos, Junho 24, 2025.

  1. Palmos

    Palmos Guest

    I have the Problem that i can't build the docker image of my angular frontend. The command RUN npm run ng build --aot --base-href=/ --configuration=dev throws a Segmentation fault error

    What I Excecute:


    docker build -t {{url}}:{{tag}} --platform linux/amd64 --build-arg conf=dev --build-arg path=frontend .

    Error:


    Terminal-Logs of the Error:


    [builder 6/7] RUN npm install \
    ERROR [builder 7/7] RUN npm run ng build --aot --base-href=/ --configuration=dev \

    [builder 7/7] RUN npm run ng build --aot --base-href=/ --configuration=dev:

    project@5.2.1 ng
    ng build

    Segmentation fault
    ------
    Dockerfile:11
    --------------------
    9 | ARG conf
    10 | RUN npm install
    11 | >>> RUN npm run ng build --aot --base-href=/ --configuration=$conf
    12 |
    13 | FROM nginx:1.25.4-alpine
    --------------------
    ERROR: failed to solve: process "/bin/sh -c npm run ng build --aot --base-href=/ --configuration=$conf" did not complete successfully: exit code: 139
    ​
    Ressources


    Here is the Docker-File:

    FROM node:18.18.2 as builder

    COPY package.json package-lock.json ./

    RUN npm ci && mkdir /ng-app
    WORKDIR /ng-app
    COPY . .

    ARG conf
    RUN npm install
    RUN npm run ng build --aot --base-href=/ --configuration=$conf


    FROM nginx:1.25.4-alpine

    COPY nginx.conf /etc/nginx/nginx.conf
    WORKDIR /usr/share/nginx/html
    COPY --from=builder /ng-app/dist/frontend .


    UPDATE: package.json

    {
    "name": "project",
    "version": "5.2.2",
    "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "lint": "ng lint",
    "compodoc": "npx compodoc -p tsconfig.doc.json",
    "cypress:eek:pen": "cypress open"
    },
    "private": true,
    "dependencies": {
    "@angular-devkit/build-angular": "^16.2.13",
    "@angular/animations": "^16.1.5",
    "@angular/cdk": "^16.2.12",
    "@angular/common": "^16.1.5",
    "@angular/compiler": "^16.1.5",
    "@angular/core": "^16.1.5",
    "@angular/forms": "^16.2.12",
    "@angular/platform-browser": "^16.1.5",
    "@angular/platform-browser-dynamic": "^16.2.12",
    "@angular/router": "^16.2.12",
    "@angular/service-worker": "^16.2.12",
    "@ngneat/tailwind": "^7.0.3",
    "@popperjs/core": "^2.11.8",
    "@zxcvbn-ts/core": "^3.0.4",
    "@zxcvbn-ts/language-en": "^3.0.2",
    "angular-password-strength-meter": "^9.0.1",
    "bootstrap-icons": "^1.11.2",
    "captcha-eu-sdk": "^1.0.2",
    "clean-deep": "^3.4.0",
    "cypress-real-events": "^1.7.6",
    "deep-object-diff": "^1.1.9",
    "eslint-plugin-deprecation": "^1.5.0",
    "google-libphonenumber": "^3.2.33",
    "keycloak-angular": "^14.1.0",
    "keycloak-js": "^22.0.5",
    "libphonenumber-js": "^1.10.51",
    "ng-recaptcha": "^12.0.2",
    "ngx-matomo-client": "^5.0.4",
    "node": "^20.10.0",
    "popper.js": "^1.16.1",
    "primeicons": "^6.0.1",
    "primeng": "^16.9.1",
    "rxjs": "^7.8.1",
    "tslib": "^2.6.2",
    "yaml": "^2.3.4",
    "zone.js": "^0.13.3"
    },
    "devDependencies": {
    "@angular-eslint/builder": "^16.3.1",
    "@angular-eslint/eslint-plugin": "^16.1.0",
    "@angular-eslint/eslint-plugin-template": "^16.1.0",
    "@angular-eslint/schematics": "^16.3.1",
    "@angular-eslint/template-parser": "^16.3.1",
    "@angular/cli": "^16.2.10",
    "@angular/compiler-cli": "^16.2.12",
    "@tailwindcss/aspect-ratio": "0.4.2",
    "@tailwindcss/forms": "^0.5.7",
    "@tailwindcss/line-clamp": "^0.4.4",
    "@tailwindcss/typography": "^0.5.10",
    "@types/jasmine": "~4.3.5",
    "@types/node": "^20.10.1",
    "@types/webpack-env": "^1.18.4",
    "@typescript-eslint/eslint-plugin": "6.1.0",
    "@typescript-eslint/parser": "6.1.0",
    "autoprefixer": "10.4.14",
    "css-minimizer-webpack-plugin": "^5.0.1",
    "cypress": "^13.6.2",
    "cypress-keycloak-commands": "^1.2.0",
    "esbuild": "^0.18.20",
    "eslint": "^8.54.0",
    "eslint-config-prettier": "^8.10.0",
    "eslint-plugin-prettier": "^5.0.1",
    "htmlhint": "^1.1.4",
    "jasmine-core": "~5.0.1",
    "karma": "~6.4.1",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.1",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.1.0",
    "postcss": "^8.4.26",
    "prettier": "^3.1.0",
    "tailwindcss": "^3.3.5",
    "typescript": "~4.9.5",
    "webpack": "^5.89.0",
    "webpack-dev-server": "^4.12.0"
    }
    }


    Docker Desktop Ressources:

    • CPU limit 8
    • Memory limit: 14 GB
    • Swap: 2 GB
    • Virtual disk limit: 192 GB
    Additional Informations


    I can execute the command without problems local (ng build --aot --base-href=/ --configuration=dev ). Other Team-Members can build the exact same docker image without problems. (One has the same error as I)

    Local Versions:

    • Angular: 16.2.12
    • Node: 18.18.2
    • npm: 10.5.1
    • OS: darwin x64 & macOS Sonoma 14.4.1
    • Docker: 25.0.3
    Steps I tried already:


    • Reinstalling Docker, angular


    • Updated Docker, Node, NPM to newer versions (not always to the latest because of angular 16.x)


    • Checked Compatibility of the modules (Angular, Node, NPM)


    • Give Docker more ressources


    • Testet command outside of docker -> It works local


    • Docker File could not be the problem, because it works for other team-members.
    What I Expect:


    I am new to docker & angular. I would be grateful for some hints how I can solve the Problems.

    Please let me know if you need any additional informations.

    Kind regards

    Update


    Another Team-Member has now the same Problems after updating his MacOS from 13.x.x to 14.4.1

    Continue reading...

Compartilhe esta Página