这就是我做一些 linter 测试 (eslint) 的方式。
linter:
image: ubuntu:16.04
stage: test
tags:
- testing
before_script:
- apt-get update -y
- apt-get install nodejs-legacy -yqq
- apt-get install curl -yqq
- curl https://install.meteor.com/ | sh
- meteor npm install eslint eslint-plugin-react
script:
- ./node_modules/.bin/eslint --ext .js --ext .jsx .
但是每次测试都必须将软件包安装到 ubuntu 镜像中,这需要时间。
所以我想用这个来构建一个图像。我想出了这个 Dockerfile:
FROM ubuntu:16.04
RUN apt-get update -y
RUN apt-get install nodejs-legacy -yqq
RUN apt-get install curl -yqq
RUN apt-get clean && apt-get autoclean && apt-get autoremove
RUN curl https://install.meteor.com/ | sh
那我做
$ docker build -t linter-testing:latest .
还有这个 yml 文件:
linter:
image: linter-testing:latest
stage: test
tags:
- testing
before_script:
- meteor npm install eslint eslint-plugin-react
script:
- ./node_modules/.bin/eslint --ext .js --ext .jsx .
但它失败并出现此错误:
ERROR: Job failed: Error response from daemon: repository linter-testing not found: does not exist or no pull access
那么为什么这个图像不存在,尽管 docker images
向我显示了那个图像...
最佳答案
您需要编辑 config.toml
文件,该文件位于运行器机器上的 /etc/gitlab-runner
中,使用以下内容
[runners.docker]
pull_policy = "if-not-present"
查看相关问题 here .
关于docker - Gitlab CI/Docker : Use custom image for job,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43481618/