前端应用程序构建突然失败

问题描述 投票:0回答:1

这是我运行工作流程时遇到的错误

#17 [final 3/6] COPY --from=builder /home/node/app/dist/apps//* /usr/share/nginx/html
#17 ERROR: lstat /var/lib/docker/tmp/buildkit-mount3999339759/home/node/app/dist/apps: no such file or directory
------
 > [final 3/6] COPY --from=builder /home/node/app/dist/apps//* /usr/share/nginx/html:
------
Dockerfile:14
--------------------
  12 |     
  13 |     RUN rm /usr/share/nginx/html/index.html
  14 | >>> COPY --from=builder /home/node/app/dist/apps/$PROJECT_NAME/* /usr/share/nginx/html
  15 |     COPY nginx/default.conf /etc/nginx/conf.d/default.conf
  16 |     COPY nginx/nginx.conf /etc/nginx/nginx.conf
--------------------
ERROR: failed to solve: lstat /var/lib/docker/tmp/buildkit-mount3999339759/home/node/app/dist/apps: no such file or directory
Error: buildx failed with: ERROR: failed to solve: lstat /var/lib/docker/tmp/buildkit-mount3999339759/home/node/app/dist/apps: no such file or directory

这是 docker 文件

FROM node:18.17-alpine AS builder
ARG PROJECT_NAME
USER node
RUN mkdir -p /home/node/app
WORKDIR /home/node/app
COPY --chown=node package.json .
RUN yarn install --verbose

COPY --chown=node . .
RUN yarn build $PROJECT_NAME production
FROM nginx:1.15.8-alpine AS final

RUN rm /usr/share/nginx/html/index.html
COPY --from=builder /home/node/app/dist/apps/$PROJECT_NAME/* /usr/share/nginx/html
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/nginx.conf
RUN apk update

工作流程是这样的

name: Build Check On PR

on:
  workflow_call:
    inputs:
      ENV_VARIABLES_PATH:
        required: true
        type: string

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3

    - name: Set Environment Variables
      uses: ./.github/actions/setvars
      with:
        varFilePath: ${{ inputs.ENV_VARIABLES_PATH }}

    - name: Set up Docker
      uses: actions/setup-node@v3
      with:
        node-version: '14'

    - name: Build check
      uses: docker/build-push-action@v2
      with:
        context: .
        build-args: |
          PROJECT_NAME=${{ env.PROJECT_NAME }}
        push: false

它在 4 天前就可以工作,现在我所做的任何事情或之前任何成功的构建都会抛出此错误。 我不明白问题出在哪里,我也查看了最新的更改,但与.github的配置无关。

reactjs dockerfile devops workflow
1个回答
0
投票

如错误消息所示

#17 [final 3/6] COPY --from=builder /home/node/app/dist/apps//* /usr/share/nginx/html
                                                             ^here

您的构建参数

PROJECT_NAME
未定义!

查看

docker/build-push-action@v2
后,
build-args
应该是一个列表,所以尝试更改为这个

    - name: Build check
      uses: docker/build-push-action@v2
      with:
        context: .
        build-args:
          - "PROJECT_NAME=${{ env.PROJECT_NAME }}" #here
        push: false
© www.soinside.com 2019 - 2024. All rights reserved.