-1

I am trying to dockerize a react application, but npm run build layer is failing and giving this error: Dockerfile

FROM node:16-alpine

WORKDIR /app/app-v2

COPY .npmrc ./

COPY package.json ./

RUN npm install --legacy-peer-deps

COPY . .

RUN npm run build:qa

RUN rm -r node_modules

# CMD ["npm", "run", "start:dev"]

CMD ["npm", "run", "serve:qa"]

I'm facing error on build layer.

 => ERROR [7/8] RUN npm run build:qa                                                                                     292.8s 
------
 > [7/8] RUN npm run build:qa:
#11 3.687 
#11 3.687 > react-app@0.1.0 build:qa
#11 3.687 > env-cmd -f .env.qa react-scripts build
#11 3.687 
#11 12.59 Creating an optimized production build...
#11 291.6 The build failed because the process exited too early. This probably means the system ran out of memory or someone called `kill -9` on the process.
------
executor failed running [/bin/sh -c npm run build:qa]: exit code: 1

Error

I'm using node v16 and npm v8, Docker Desktop, Windows 11 64

1 Answers1

0

Seems your server does not have enough system memory to build your project. In general, I would recommend 1GB memory on your vps or if using a windows OS then it depends on the version. It would be helpful to provide the amount of memory available on your host. Some reference on docker system requirements: Docker requirements

Edtimer
  • 244
  • 3
  • 9