![](/img/trans.png)
[英]Docker build for React App failing in Gitlab CI runner
[英]React app build is failing when building a docker image
我正在嘗試對反應應用程序進行 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"]
我在構建層上遇到錯誤。
=> 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
錯誤我正在使用節點 v16 和 npm v8
似乎您的服務器沒有足夠的系統 memory 來構建您的項目。 一般來說,我會在您的 vps 上推薦 1GB memory,或者如果使用 windows 操作系統,則取決於版本。 提供主機上可用的 memory 數量會很有幫助。 docker 系統要求的一些參考: Docker 要求
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.