docker-Gitlab、GitLab Runner安装

摘要:
映射到主机的/data/locker/gitlab/config。② 由于我们没有使用默认的暴露端口来配置GitLab,因此我们需要修改/data/locker/GitLab/config/GitLab.rb。一、 修改external_url:#ForHTTPexternal_url“http://115.30.149.35:8888“或用于HTTPSexternal_url”http://115.30.149.35:8888“II.修改gitlab_shell_ssh_port:itlab_rails['gitlab_shell_ssh_port']=24有关更多配置信息,请参阅官方文档http://115.30.149.35:8888官方推荐的是4G内存,启动gitlab非常需要CPU。单核2Ggitlab启动服务器卡住了。解决方案:https://yq.aliyun.com/articles/520982.GitlabRunner安装① 安装gitlabrunnerrpm包。选择适合您系统的gitlabrunner包https://gitlab-runner-downloads.s3.amazonaws.com/latest/index.htmlcurl-LJOhttps://gitlab-runner-downloads.s3.amazonaws。com/最新/rpm/gitlab-runner_Amd64.rpm② 安装rpm包rpm igitlab runner_Amd64.rpm③ 注册Runner I,运行以下命令gitlab runnerregister II,输入您的GitLabinstanceURL:请输入gitlab cicordatorURLhttp://115.30.149.35:8888III.输入您获得的令牌以获得跑步者:请输入此lunnerhUCad4cXYPEKTttoken的gitlab citokenabhttp://115.30.149.35:88882单击刀具3。概览-˃运行器的红色框指示令牌。

以下操作均在CentOs下操作

1、Gitlab install

① 启动gitlab

docker run --detach 
  --hostname 115.30.149.35 
  --publish 8888:8888 --publish 24:22 
  --name gitlab 
  --restart always 
  --volume /data/docker/gitlab/config:/etc/gitlab 
  --volume /data/docker/gitlab/logs:/var/log/gitlab 
  --volume /data/docker/gitlab/data:/var/opt/gitlab 
  --privileged=true 
  gitlab/gitlab-ce:latest

--hostname 当前服务器的域名

--publish 24:22 SSH访问端口 默认22:22

--publish 8888:8888 http访问的端口 默认是80:80

--publish 443:443 https访问的端口

--privileged=true 授权

--volume 三个卷挂载gitlab的数据,需要提前创建好

443是https端口 80默认是http端口 根据官网文档,更改端口需要更改对应的配置文件。所在的配置信息存放在

/etc/gitlab/gitlab.rb。映射在主机的/data/docker/gitlab/config。

② 配置GitLab

由于我们没用使用默认的暴露端口,因此需要修改 /data/docker/gitlab/config/gitlab.rb

Ⅰ、修改external_url:

# For HTTP external_url "http://115.30.149.35:8888"

or

For HTTPS (notice the https)

external_url "http://115.30.149.35:8888"

Ⅱ、修改gitlab_shell_ssh_port:

itlab_rails['gitlab_shell_ssh_port'] = 24

更多配置信息可以参考官方文档。

③ 重启gitlab

docker restart gitlab

④ 访问gitlab

浏览器输入 http://115.30.149.35:8888

微信截图_20200202103524

官方建议4G内存,启动gitlab很吃CPU。

1核2G gitlab启动服务器卡死。解决方案:

https://yq.aliyun.com/articles/52098

2、Gitlab Runner Install

①安装gitlab-runnner rpm包

在这里选择适合你系统的gitlab runner包https://gitlab-runner-downloads.s3.amazonaws.com/latest/index.html

curl -LJO https://gitlab-runner-downloads.s3.amazonaws.com/latest/rpm/gitlab-runner_amd64.rpm

②安装rpm 包

rpm -i gitlab-runner_amd64.rpm

③注册Runner

Ⅰ、Run the following command

gitlab-runner register

Ⅱ、Enter your GitLab instance URL:(GitLab实例地址,上面GitLab的地址)

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com )
http://115.30.149.35:8888

Ⅲ、Enter the token you obtained to register the Runner(输入注册Runner的token):

Please enter the gitlab-ci token for this runner
hUCad4cXYPEKTt

token所在地方:

​ 1、登入GitLabhttp://115.30.149.35:8888

​ 2、点击工具刀

image-20200202105115209

​ 3、Overview->Runners

image-20200202105244186

红色框里面即为token。

Ⅳ、Enter a description for the Runner, you can change this later in GitLab’s UI(添加Runner描述):

Please enter the gitlab-ci description for this runner
my-runner

Ⅴ、Add a Tag

Please enter the gitlab-ci tags for this runner (comma separated):

Ⅵ、Enter the Runner executor:

Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell: 
shell

④刷新GitLab页面

image-20200202105927183

可看到注册的Runner。

3、提交项目到gitlab

1、创建一个项目

2、按照提示将我们的项目提交到gitlab上(Push an existing folder)

git remote add origin http://115.30.149.35:8888/root/miniserver-userapi.git

image-20200131121109611

关闭VS

image-20200131121425770

git push 的提示要输入gitlab的用户名和密码

编写以下.gitlab-ci.yml文件(需要放在整个项目的根目录)

提交 在具体的project 的CICD下即可看到项目在跑

4、问题集合

问题一、

image-20200201113817157

docker gitlab 的用户组没有加入docker

usermod -aG docker gitlab-runner
sudo service docker restart
问题二、某次CI失败后再启动

fatal: git fetch-pack: expected shallow list

fatal: The remote end hung up unexpectedly

原因是git版本太老不持之新API,需要升级一下git:

#安装源
yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm
#安装git
yum install git
#更新git
yum update git

参考资料:

Gitlab:https://docs.gitlab.com/omnibus/docker/

GitLab Runner:https://docs.gitlab.com/runner/install/linux-manually.html

免责声明:文章转载自《docker-Gitlab、GitLab Runner安装》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇python ddt数据驱动二(json, yaml 驱动)logback 三下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

使用Docker部署Gitlab

  1. 拉取gitlab镜像 docker pull gitlab/gitlab-ce 2. 运行gitlab实例   GITLAB_HOME=`pwd`/data/gitlab docker run -d --hostname gitlab --publish 8443:443 --publish 80:80 --publish...

python 安装 pip ,并使用pip 安装 filetype

闲话少说,直接上操作。 python版本为2.7.6 可以直接到官网下载,我也提供一个百度云的下载地址https://pan.baidu.com/s/1kWPXG8Z 这个是window版本,linux版本的自行到其他地方下载。 开发工具我使用的是pycharm4.5.3,目前有破解版本,下载地址https://pan.baidu.com/s/1pMU9o...

Ubuntu 使用 Android Studio 编译 TensorFlow android demo

https://www.cnblogs.com/dyufei/p/8028218.html https://www.myboxlab.com/topic/detail/714ca2d405414f1397140f996b1d8733.html https://blog.csdn.net/masa_fish/article/details/54097796...

nginx 之 https 证书配置

HTTPS原理和作用 为什么需要HTTPS 原因:HTTP不安全 传输数据被中间人盗用、信息泄露 数据内容劫持、篡改 HTTPS协议的实现 对传输内容进行加密以及身份验证 对称加密:加密秘钥和解密秘钥是对等的,一样的 非对称加密: HTTPS加密协议原理:   中间人伪造客户端和服务端:(中间人可以伪装成客户端和服务端,中间人可以对数据进行劫持,不...

charles抓包工具的使用:手机抓包设置和安装证书

    一. 设置手机抓包 第一步:在charles里设置允许手机联网的权限,并设置接入接口 在Charles的菜单栏上选择"Proxy"->"Proxy Settings",填入代理端口8888(注意,这个端口不一定填写8888,也可以写别的端口),并且勾上”Enable transparent HTTP proxying”,这样就完成了在Cha...

layui 学习笔记(四) 复杂表头前台Excel导出

layui - excel 复杂表头导出- 第三方插件实现 参考:https://fly.layui.com/extend/excel/演示:http://excel.wj2015.com/    http://excel.wj2015.com/_book/docs/%E5%87%BD%E6%95%B0%E5%88%97%E8%A1%A8/%E5%AF%B...