創(chuàng)建私有網(wǎng)絡(luò)self
docker network create --driver=bridge self
部署gitlab
docker volume create gitlab-runner-config
docker pull gitlab/gitlab-ce
docker run -d --name gitlab -h gitlab.cza.orz --network=self --network-alias=gitlab.cza.orz -p 443:443 -p 80:80 -p 22:22 -v gitlab-runner-config:/etc/gitlab -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-ce
修改gitlab部分參數(shù),減少資源消耗
docker exec -it gitlab bash
# vim /etc/gitlab/gitlab.rb
>>> 修改如下內(nèi)容
unicorn['worker_processes'] = 2
unicorn['worker_memory_limit_min'] = "300 * 1 << 20"
unicorn['worker_memory_limit_max'] = "500 * 1 << 20"
sidekiq['concurrency'] = 4
prometheus_monitoring['enable'] = false
postgresql['shared_buffers'] = 256M
<<<
# gitlab-ctl reconfigure
# exit
docker restart gitlab
登錄時(shí)指定通用密碼,登錄賬號(hào)為root
部署gitlab-runner
docker pull gitlab/gitlab-runner
docker volume create gitlab-runner-config
docker run -d --name gitlab-runner --network=self -v gitlab-runner-config:/etc/gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner
啟動(dòng)runner后還需注冊(cè)runner到gitlab, 注冊(cè)過程中需要填入gitlab的地址與token窜骄,可以指定自己特殊使用的runner
docker run --rm -it --network=self -v gitlab-runner-config:/etc/gitlab-runner gitlab/gitlab-runner register
或者使用下面命令行直接輸入
docker run --rm -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \
--non-interactive \
--executor "docker" \
--docker-image alpine:latest \
--url "https://gitlab.com/" \
--registration-token "PROJECT_REGISTRATION_TOKEN" \
--description "docker-runner" \
--tag-list "docker,aws" \
--run-untagged="true" \
--locked="false" \
--access-level="not_protected"
在項(xiàng)目settings.cicd種配置runner即可