简体   繁体   English

构建 docker 映像时,React 应用构建失败

[英]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

Error I'm using node v16 and npm v8错误我正在使用节点 v16 和 npm v8

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.

相关问题 为 React App 构建的 Docker 在 Gitlab CI runner 中失败 - Docker build for React App failing in Gitlab CI runner 使用 docker-compose 构建应用程序时,如何在 React 应用程序中为 URL 端点使用 Docker 容器名称? - How to use Docker container name for URL endpoint in React app when building app with docker-compose? 尝试访问本地 API 端点时,React/Next.js docker 构建失败 - React/Next.js docker build failing when trying to reach out to local API endpoint Docker 映像无法在 AWS EC2 linux 上构建,但在 Windows 和 Mac 上构建时有效 - Docker image failing to build on AWS EC2 linux but works when built on Windows and Mac 使用 https 构建 Nuxt 应用程序的 docker 映像 - Building docker image of Nuxt app with https 为登台和生产环境构建docker映像时,我应该在哪里执行grunt构建步骤? - Where should i run my grunt build step when building my docker image for staging and production environments? docker 构建镜像时找不到模块 - docker Cannot find module when building image 在使用Docker构建节点应用程序映像时,如何摆脱package-lock.json警告? - How to get rid of the package-lock.json warning when building a node app image with Docker? Create React App 无法在 docker 内部构建 - Create React App fails to build inside docker React 应用程序构建在 Jenkins 中的 Docker 中失败,但不是在本地 - React app build fails in Docker in Jenkins, but not locally
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM