簡體   English   中英

Docker 紗線構建失敗,退出代碼為 1

[英]Docker yarn build failed with exit code 1

我正在嘗試使用 docker 構建我的 React 應用程序,當我在本地運行 npm run build 時它成功構建,但是當我使用 docker 構建時,它在構建階段失敗。

我的碼頭檔案

FROM node:alpine as builder
WORKDIR /app
COPY package.json .
COPY yarn.lock .
RUN yarn
COPY . .
RUN yarn build

# => Run container
FROM nginxinc/nginx-unprivileged:mainline-alpine

# Nginx config
#RUN rm -rf /etc/nginx/conf.d
#COPY conf /etc/nginx

# Static build
COPY --from=builder /app/build /usr/share/nginx/html/
COPY default.conf /etc/nginx/conf.d/

# Default port exposure
EXPOSE 80

# Copy .env file and shell script to container
WORKDIR /usr/share/nginx/html
COPY ./env.sh .
COPY .env .
USER root
# Add bash
RUN apk add --no-cache bash

# Make our shell script executable
RUN chmod +x env.sh

# Start Nginx server
CMD ["/bin/bash", "-c", "/usr/share/nginx/html/env.sh && nginx -g \"daemon off;\""]

運行命令 docker build -t project 。 下面是輸出

 > [builder 7/7] RUN yarn build --no-cache=true:
#14 1.278 yarn run v1.22.5
#14 1.361 $ react-scripts build --no-cache=true
#14 3.409 Creating an optimized production build...
#14 5.746 Failed to compile.
#14 5.746
#14 5.747 ./src/index.js
#14 5.747 TypeError: invalid options argument
#14 5.747     at new Promise (<anonymous>)
#14 5.747     at Generator.throw (<anonymous>)
#14 5.747
#14 5.747
#14 5.778 error Command failed with exit code 1.
#14 5.778 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------
executor failed running [/bin/sh -c yarn build --no-cache=true]: exit code: 1

好的,只是缺少 pacakge-lock.json 文件。 問題解決了

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM