我的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
运行器的输出:
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
文件中的构建任务是发生故障的时间:
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
任何人都可以提出解决方案或解释导致构建失败的原因吗?
答案 0 :(得分:0)
这似乎与Docker最近的变化有关,该变化与gitlab
冲突,请参见此处:
https://gitlab.com/gitlab-org/gitlab-runner/issues/4501
我尝试了发布在此处的解决方案,但只能通过使用gitlab共享运行程序而不是我自己的运行程序来使运行程序重新工作。