Ng build: Optimization error while building in docker

  angular, docker, node.js, npm

While building an Angular app in docker I get the following error upon reaching npm run build:

#11 1.106 > ng build
#11 1.106
#11 4.769 - Generating browser application bundles (phase: setup)...
#11 32.23 ✔ Browser application bundle generation complete.
#11 32.24 ✔ Browser application bundle generation complete.
#11 32.25
#11 32.25 Error: Optimization error [runtime.da6be98804527182b005.js]: Error: The service was stopped
#11 32.25     at /app/node_modules/esbuild/lib/main.js:1258:29
#11 32.25     at /app/node_modules/esbuild/lib/main.js:611:9
#11 32.25     at Socket.afterClose (/app/node_modules/esbuild/lib/main.js:589:7)
#11 32.25     at Socket.emit (node:events:402:35)
#11 32.25     at endReadableNT (node:internal/streams/readable:1343:12)
#11 32.25     at processTicksAndRejections (node:internal/process/task_queues:83:21)

My docker file:

# BUILD
FROM node:16-alpine as build
WORKDIR /app
COPY ./ /app
RUN npm install
RUN npm run build


# SERVE
FROM nginx:1.21.3-alpine
COPY --from=build /app/dist/portfolio-website /usr/share/nginx/html
EXPOSE 80

What am I doing wrong and what should I do?

Source: Docker Questions

LEAVE A COMMENT