安裝gitlab
1 docker pull gitlab/gitlab-ce
2
docker run -d \
-p 443:443 -p 8088:8088 \
-p 222:22 \
--name mmy-gitlab \
--restart always \
-v /usr/local/gitlab/config:/etc/gitlab \
-v /usr/local/gitlab/logs:/var/log/gitlab \
-v /usr/local/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce
-d:后臺運(yùn)行
-p:將容器內(nèi)部端口向外映射
--name:命名容器名稱
-v:將容器內(nèi)數(shù)據(jù)文件夾或者日志、配置等文件夾掛載到宿主機(jī)指定目錄
3 修改配置文件 vim /home/gitlab/config/gitlab.rb
# 配置http協(xié)議所使用的訪問地址,不加端口號默認(rèn)為80
external_url 'http://39.98.138.27'
# 配置ssh協(xié)議所使用的訪問地址和端口
gitlab_rails['gitlab_ssh_host'] = '39.98.138.27'
#此端口是run時22端口映射的222端口
gitlab_rails['gitlab_shell_ssh_port'] = 222
:wq
4 重啟鏡像 docker restart gitlab
5 訪問http://39.98.138.27
,root用戶密碼筹裕,訪問成功
安裝gitlab-runner
官網(wǎng)地址: https://docs.gitlab.com/runner/
1 安裝gitlab-runner
需要安裝git
curl https://setup.ius.io | sh
yum remove -y git // 刪除舊版本
yum -y install git2u
git version
2 第一種安裝:docker 安裝
docker run -d --name gitlab-runner --restart always \
-v /home/gitlab-runner/config:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest
#注冊
docker exec -it gitlab-runner gitlab-ci-multi-runner register
3 第二種安裝:命令安裝
官方文檔: https://docs.gitlab.com/runner/install/linux-manually.html
sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
sudo chmod +x /usr/local/bin/gitlab-runner
#創(chuàng)建用戶
sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
sudo gitlab-runner start
#注冊
gitlab-runner register
4
5
6 如果CI配置中執(zhí)行docker 命令比藻,將gitlab-runner用戶添加到docker組
sudo usermod -aG docker gitlab-runner
驗(yàn)證是否生效:
sudo -u gitlab-runner -H docker info