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
I'm using node v16 and npm v8, Docker Desktop, Windows 11 64