首先,我正在检查测试docker镜像,我在gitlab CI中使用它作为docker runner:
如果docker容器( testing
)在里面运行此命令...
meteor npm list --depth=0
给了我一个预期的结果:
npm info it worked if it ends with ok
npm info using npm@5.4.2
npm info using node@v8.6.0
project@1.0.0 /builds/namespace/project
+-- autoprefixer@7.1.5
+-- babel-runtime@6.26.0
+-- bcrypt@1.0.3
+-- fluent-ffmpeg@2.1.2
+-- gm@1.23.0
+-- gridfs-stream@1.1.1
+-- react@16.0.0
因此所有依赖项都安装在docker镜像中 . 现在我在我的gitLab CI中使用这个图像:
我的gitLab CI yml文件如下所示:
unit:
image: testing:latest
stage: unit
tags:
- testing
script:
- meteor npm list --depth=0
但结果是:
npm info it worked if it ends with ok
npm info using npm@5.4.2
npm info using node@v8.6.0
project@1.0.0 /builds/namespace/project
+-- UNMET DEPENDENCY autoprefixer@7.1.4
+-- UNMET DEPENDENCY babel-runtime@6.26.0
+-- UNMET DEPENDENCY bcrypt@1.0.3
+-- UNMET DEPENDENCY fluent-ffmpeg@2.1.2
+-- UNMET DEPENDENCY gm@1.23.0
+-- UNMET DEPENDENCY gridfs-stream@1.1.1
+-- UNMET DEPENDENCY react@15.6.0
为什么没有安装依赖项?每次CI运行作业时,我都不想安装它们 . 相反,我希望已经安装在docker镜像中的所有dependecies更快地获得它 .
Update
运行CI阶段,没有 node_modules
目录,该目录存在于docker镜像中...如何阻止gitlab删除该文件夹?
1 回答
这是因为当构建开始时,它再次取回你的repo,基本上用新的克隆覆盖内容 . 最快的解决方法是暂时将依赖项移动到其他文件夹,然后在实际构建期间将其移回 . 例如执行
meteor npm install
将node_modules
移动到/example/node_modules
然后在构建期间将它们移回/builds/namespace/project/node_modules