[英]React app build is failing when building a docker image
I am trying to dockerize a react application, but npm run build
layer is failing and giving this error: Dockerfile我正在尝试对反应应用程序进行 docker 化,但npm run build
层失败并出现此错误: 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
Seems your server does not have enough system memory to build your project.似乎您的服务器没有足够的系统 memory 来构建您的项目。 In general, I would recommend 1GB memory on your vps or if using a windows OS then it depends on the version.一般来说,我会在您的 vps 上推荐 1GB memory,或者如果使用 windows 操作系统,则取决于版本。 It would be helpful to provide the amount of memory available on your host.提供主机上可用的 memory 数量会很有帮助。 Some reference on docker system requirements: Docker requirements docker 系统要求的一些参考: Docker 要求
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.