为什么Create React App构建在Gitlab CI Runner中失败? [英] Why is Create React App build failing in Gitlab CI Runner?

查看:125
本文介绍了为什么Create React App构建在Gitlab CI Runner中失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Dockerfile的内容:

The contents of my Dockerfile:

FROM node:alpine as builder

WORKDIR /usr/src/app

COPY package.json . 

RUN npm install

COPY . .

RUN npm run build  || cat /root/.npm/_logs/*.log

FROM nginx 

COPY --from=builder /usr/src/app/build /usr/share/nginx/html

我已将其配置为与自己的 gitlab一起运行跑步者。直到我上次尝试构建之前,这一切都很好。在我自己的机器上,它可以毫无问题地构建。只有当 gitlab 运行器尝试构建它时,它才会失败。我所做的唯一更改是在Web应用程序中安装了一些额外的库。以下是 gitlab 运行器的输出:

I've configured this to run with my own gitlab runner. This was working fine until the last time I attempted a build. On my own machine it builds without issue. Only when the gitlab runner attempts to build it does it fail. Only changes I made were to install some extra libraries inside my web app. Here is the output of the gitlab runner:

Running with gitlab-runner 12.0.0 (6946bae7)
  on chargo-runner r1N7i14n
Using Docker executor with image docker:stable ...
Starting service docker:dind ...
Pulling docker image docker:dind ...
Using docker image sha256:fd0c64832f7e46b63a180e6000dbba7ad7a63542c5764841cba73429ba74a39e for docker:dind ...
Waiting for services to be up and running...

*** WARNING: Service runner-r1N7i14n-project-10187987-concurrent-0-docker-0 probably didn't start properly.

Health check error:
service "runner-r1N7i14n-project-10187987-concurrent-0-docker-0-wait-for-service" timeout

Health check container logs:

...

2019-07-27T09:17:36.285748935Z time="2019-07-27T09:17:36.285428543Z" level=warning msg="Running modprobe bridge br_netfilter failed with message: ip: can't find device 'bridge'\nbridge                151552  1 br_netfilter\nstp                    16384  1 bridge\nllc                    16384  2 bridge,stp\nip: can't find device 'br_netfilter'\nbr_netfilter           24576  0 \nbridge                151552  1 br_netfilter\nmodprobe: can't change directory to '/lib/modules': No such file or directory\n, error: exit status 1"

...

Pulling docker image docker:stable ...
Using docker image sha256:c4154a2b47a18fe9437956ab981bd5924b19e7ae3eb3ed60c42cf8dfa394d550 for docker:stable ...
Running on runner-r1N7i14n-project-10187987-concurrent-0 via ubuntu-s-1vcpu-1gb-lon1-01...
Fetching changes...
Reinitialized existing Git repository in /builds/chargo/chargoworkspace/.git/
Checking out 7ec3cfc1 as master...
Removing adminapp/coverage/
Removing adminapp/node_modules/

Skipping Git submodules setup
Checking cache for master...
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted. 
Successfully extracted cache
$ docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
$ docker build -t $DOCKER_ADMAPP_IMAGE_TAG -f adminapp/Dockerfile ./adminapp
Sending build context to Docker daemon  201.4MB

Step 1/8 : FROM node:alpine as builder
alpine: Pulling from library/node
e7c96db7181b: Pulling fs layer
72484f09da35: Pulling fs layer
86bee4bed5f2: Pulling fs layer
f9e983f0fe2c: Pulling fs layer
f9e983f0fe2c: Waiting
e7c96db7181b: Verifying Checksum
e7c96db7181b: Download complete
86bee4bed5f2: Verifying Checksum
86bee4bed5f2: Download complete
72484f09da35: Verifying Checksum
72484f09da35: Download complete
e7c96db7181b: Pull complete
f9e983f0fe2c: Verifying Checksum
f9e983f0fe2c: Download complete
72484f09da35: Pull complete
86bee4bed5f2: Pull complete
f9e983f0fe2c: Pull complete
Digest: sha256:300e3d2c19067c1aec9d9b2bd3acbd43d53797a5836d70a23e437a5634bcd33a
Status: Downloaded newer image for node:alpine
 ---> d97a436daee9
Step 2/8 : WORKDIR /usr/src/app
 ---> Running in 7c3a1727f367
Removing intermediate container 7c3a1727f367
 ---> dfe2f6cb09f7
Step 3/8 : COPY package.json .
 ---> f22d985084b4
Step 4/8 : RUN npm install
 ---> Running in 2505724f412d
npm WARN deprecated fsevents@2.0.6: Please update: there are crash fixes
npm WARN deprecated core-js@1.2.7: core-js@<2.6.8 is no longer maintained. Please, upgrade to core-js@3 or at least to actual version of core-js@2.
npm WARN deprecated flatten@1.0.2: I wrote this module a very long time ago; you should use something else.
npm WARN deprecated left-pad@1.3.0: use String.prototype.padStart()

> core-js@2.6.9 postinstall /usr/src/app/node_modules/core-js
> node scripts/postinstall || echo "ignore"


The command '/bin/sh -c npm install' returned a non-zero code: 1
ERROR: Job failed: exit code 1

我的 .gitlab-ci.yml 文件是发生故障的时间:

The build task in my .gitlab-ci.yml file is when the failure occurs:

variables:
    DOCKER_ADMAPP_IMAGE_TAG: ${CI_REGISTRY_IMAGE}/adminapp:${CI_COMMIT_SHORT_SHA}
build:
    tags: [docker]
    stage: build
    image: docker:stable
    services:
        - docker:dind
    before_script:
        - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    script:
        - docker build -t $DOCKER_ADMAPP_IMAGE_TAG -f adminapp/Dockerfile ./adminapp
        - docker push $DOCKER_ADMAPP_IMAGE_TAG 

有人可以提出解决方案或解释导致构建失败的原因吗?

Can anyone suggest a solution or explain what is causing the build to fail?

推荐答案

这似乎与最近对Docker的更改感到困惑有关使用 gitlab 进行引用,请参见此处:

This seems to be an issue to do with a recent change in Docker which is conflicting with gitlab see here:

https://gitlab.com/gitlab-org/gitlab-runner/issues/4501

我尝试了此处发布的解决方案,但只能通过使用gitlab共享运行程序而不是我自己的运行程序来使运行程序再次运行。

I tried the solutions posted there but could only get my runner working again by resorting to using the gitlab shared runners instead of my own.

这篇关于为什么Create React App构建在Gitlab CI Runner中失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆