我一直在尝试使用共享运行程序设置gitlab ci。我的.gitlab-ci.yml看起来像这样:
image: docker:latest
# When using dind, it's wise to use the overlayfs driver for
# improved performance.
variables:
DOCKER_DRIVER: overlay2
GCP_PROJECT_ID: example-12345
IMAGE_NAME: test
services:
- docker:dind
stages:
- publish
publish-image:
stage: publish
script:
# Create our image. Expected to create an image 'image_id'
- docker build -t $IMAGE_NAME .
# Tag our image for container registry
- docker tag $IMAGE_NAME eu.gcr.io/$GCP_PROJECT_ID/$IMAGE_NAME
# Install CA certs, openssl to https downloads, python for gcloud sdk
- apk add --update make ca-certificates openssl python
- update-ca-certificates
# Download and install Google Cloud SDK
- wget https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz
- tar zxvf google-cloud-sdk.tar.gz && ./google-cloud-sdk/install.sh --usage-reporting=false --path-update=true
- google-cloud-sdk/bin/gcloud --quiet components install kubectl
- google-cloud-sdk/bin/gcloud --quiet components update
- google-cloud-sdk/bin/gcloud auth activate-service-account --key-file g.json
# Optionally tag the image with the commit short-sha
- docker tag $IMAGE_NAME eu.gcr.io/$GCP_PROJECT_ID/$IMAGE_NAME:$(echo $CI_COMMIT_SHA | cut -c1-8)
#- google-cloud-sdk/bin/gcloud docker -- push eu.gcr.io/$GCP_PROJECT_ID/$IMAGE_NAME:latest
- google-cloud-sdk/bin/gcloud docker -- push eu.gcr.io/$GCP_PROJECT_ID/$IMAGE_NAME:$(echo $CI_COMMIT_SHA | cut -c1-8)
# Only run builds for these refs
only:
- master
我正在尝试构建的项目是Meteor应用程序(Meteor版本1.6.1),它应该在kubernetes集群中运行。为了创建容器,我正在使用https://github.com/jshimko/meteor-launchpad。
当我在本地机器上使用docker build时,一切正常,但是在CI中我得到了这个错误(在阶段Running npm install in the server bundle...
中构建之后):
> node-pre-gyp install --fallback-to-build
module.js:540
throw err;
^
Error: Cannot find module '../'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/opt/meteor/dist/bundle/programs/server/npm/node_modules/.bin/node-pre-gyp:15:20)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bcrypt@1.0.3 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@1.0.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-03-08T13_29_09_532Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! meteor-dev-bundle@ install: `node npm-rebuild.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the meteor-dev-bundle@ install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-03-08T13_29_09_574Z-debug.log
但我不相信这是一个真正的流星问题,因为我知道代码有效。 另一个奇怪的事情是,在运行meteor 1.5.2.2(新版本为1.6.1)的旧版本代码中构建实际上是成功的,但是当它在kubernetes中运行时它会中断。来自pod的错误如下:
=> Starting app on port 3000...
## There is an issue with `node-fibers` ##
`/opt/meteor/dist/bundle/programs/server/node_modules/fibers/bin/linux-x64-57/fibers.node` is missing.
Try running this to fix the issue: /opt/nodejs/bin/node /opt/meteor/dist/bundle/programs/server/node_modules/fibers/build
/opt/meteor/dist/bundle/programs/server/node_modules/fibers/fibers.js:20
throw new Error('Missing binary. See message above.');
^
Error: Missing binary. See message above.
at Object.<anonymous> (/opt/meteor/dist/bundle/programs/server/node_modules/fibers/fibers.js:20:8)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
暂停来自跑步者的构建日志:
> fibers@1.0.15 install /opt/meteor/dist/bundle/programs/server/node_modules/fibers
> node build.js || nodejs build.js
`linux-x64-46` exists; testing
Binary is fine; exiting
由于我知道构建可以成功,因此我假设docker-in-docker在共享运行程序上使用正确的设置运行。通过运行特权将外部docker套接字绑定到内部och(如描述here和here)
那么为什么我的构建在CI上被破坏/失败?
编辑:我的本地版本在ubuntu 16上完成