2

我有一台运行 Gitlab 的服务器。假设地址是https://gitlab.mydomain.com

现在我想要实现的是安装一个持续集成系统。因为我使用的是 Gitlab,所以我选择了 Gitlab CI,因为它感觉更自然。所以我去 Docker repo 找到了这张图片

所以我运行图像以创建具有以下内容的容器

docker run --restart=always -d -p 9000:9000 -e GITLAB_URLS="https://gitlab.mydomain.com" anapsix/gitlab-ci

我给它一分钟的启动时间,现在我可以通过 URL 访问 CI http://gitlab.mydomain.com:9000。到目前为止,一切都很好。

我登录 CI 并收到以下消息:

Now you need Runners to process your builds.

所以我回到 Docker Hub 并找到了另一个图像。显然,要启动此图像,我必须以交互方式进行。我按照说明进行操作,它将创建配置文件:

mkdir -p /opt/gitlab-ci-runner
docker run --name gitlab-ci-runner -it --rm -v /opt/gitlab-ci-runner:/home/gitlab_ci_runner/data sameersbn/gitlab-ci-runner:5.0.0-1 app:setup

交互式设置将询问我所需的正确数据:

Please enter the gitlab-ci coordinator URL (e.g. http://gitlab-ci.org:3000/ )
http://gitlab.mydomain.com:9000/
Please enter the gitlab-ci token for this runner: 
12345678901234567890
Registering runner with registration token: 12345678901234567890, url: http://gitlab.mydomain.com:9000/.
Runner token: aaaaaabbbbbbcccccccdddddd
Runner registered successfully. Feel free to start it!

我去http://gitlab.mydomain:9000/admin/runners,万岁,赛跑者出现在舞台上。

一切似乎都很好,但问题来了

如果我重新启动机器,由于更新或任何原因,跑步者不再存在。当我运行跑步者的图像时,我可能会添加--restart=always到命令中,但这会出现问题,因为:

  1. 该设置是交互式的,因此必须手动输入注册跑步者的令牌
  2. 每次重新运行带有 Gitlab CI 的容器时,注册新运行器的令牌都是不同的。

我该如何解决这个问题?

4

1 回答 1

0

I have a way of pointing you in the right direction but im trying to make it myself, hope we both manage to get it up heres my situation.

im using coreOS + docker trying to do exactly what youre trying to do, and in coreOS you can setup a service that starts the CI everytime you restart the machine (as well as gitlab and the others) my problem is trying to make that same installation automatic.

after some digging i found this: https://registry.hub.docker.com/u/ubergarm/gitlab-ci-runner/

in this documentation they state that they can do it in 2 ways:

  • 1-Mount in a .dockercfg file containing credentials into the /root directory

  • 2-start your container with this info:

  • -e CI_SERVER_URL=https://my.ciserver.com \

  • -e REGISTRATION_TOKEN=12345678901234567890 \

Meaning you can setup to auto start the CI with your configs, ive been trying this for 2 days if you manage to do it tell me how =(

于 2014-12-02T17:07:11.957 回答