Alex Dai Playground

[Docker] GitLab CI 設定

| Comments

已存在的 gitlab 容器

cmd
$ docker-compose ps
            Name                          Command               State              Ports                         
------------------------------------------------------------------------------------------------------
dockergitlab_gitlab-runner_1   /entrypoint run --user=git ...   Up                                                            
dockergitlab_gitlab_1          /sbin/entrypoint.sh app:start    Up      0.0.0.0:10022->22/tcp, 443/tcp, 0.0.0.0:10080->80/tcp 
dockergitlab_postgresql_1      /sbin/entrypoint.sh              Up      5432/tcp                                              
dockergitlab_redis_1           /sbin/entrypoint.sh              Up      6379/tcp     

設定 註冊 gitlab-runner

cmd
$ docker exec -it dockergitlab_gitlab-runner_1 gitlab-runner register

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/ci )
$ http://gitlab.alex.dai.com:10080/ci

Please enter the gitlab-ci token for this runner
$ a60b0ac5e158ca0da75a348dd911ab

Please enter the gitlab-ci description for this runner
$ node-4.1.1

Please enter the gitlab-ci tag for this runner
$ node-4.1.1

Please enter the executor: docker, docker-ssh, ssh, shell, parallels:
$ docker

Please enter the Docker image (eg. ruby:2.1):
$ node:4.1.1

If you want to enable mysql please enter version (X.Y) or enter latest?

If you want to enable postgres please enter version (X.Y) or enter latest?

If you want to enable redis please enter version (X.Y) or enter latest?

If you want to enable mongo please enter version (X.Y) or enter latest?

Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!


結果



P.S: 我在一開始無法正常 bulid

因為我是 win10 所以用 virtualbox 裝 Ubuntu 再用 ssh 登入,且為了 gitlab 能在本地端使用 Google OAuth 登入,因此修改了本地 DNS 設定。

C:\Windows\System32\drivers\etc\hosts
192.168.56.1       gitlab.alex.dai.com

192.168.56.1 是本地 virtualbox 的網卡ip ,我是對應到 10.0.2.15 這個 virtualbox 內部 ip。

所以關於 host 設定不能用 gitlab.alex.dai.com 這個自己設定的網域,否則 gitlab runner 會無法送出請求到 gitlab。

修正如下:

docker-compose.yml
  gitlab:

  ...

  ...

- GITLAB_HOST=192.168.56.1
cmd docker exec -it dockergitlab_gitlab-runner_1 gitlab-runner register
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/ci )
$ http://192.168.56.1:10080/ci

收工!!!

我覺得還是直接在 Linux 的環境下操作比較沒問題,原本是要在 AWS EC2 上操作的,想不到試用期的免費主機的記憶體只有1G(實際可用700多MB),導致常常出現 502 error、CPU 飆高,gitlab 最後直接死掉無法瀏覽..

References

Comments

comments powered by Disqus