原创文章,欢迎转载。转载请注明:转载自IT人故事会,谢谢!
原文链接地址:『中级篇』docker之CI/CD持续集成-gitlab安装(70)
gitlab在持续化集成中非常的重要,它用于开发人员进行提交代码关于代码的库,本次安装还是使用vagrant的方式。源码:https://github.com/limingios/docker/tree/master/No.11
创建虚拟机
- vagrant文件的配置
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.require_version ">= 1.6.0"
boxes = [
{
:name => "gitlab",
:mem => "4096",
:cpu => "2"
}
]
Vagrant.configure(2) do |config|
config.vm.box = "centos/7"
boxes.each do |opts|
config.vm.define opts[:name] do |config|
config.vm.hostname = opts[:name]
config.vm.provider "vmware_fusion" do |v|
v.vmx["memsize"] = opts[:mem]
v.vmx["numvcpus"] = opts[:cpu]
end
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--memory", opts[:mem]]
v.customize ["modifyvm", :id, "--cpus", opts[:cpu]]
end
config.vm.network :private_network, type: "dhcp"
end
end
config.vm.provision "shell", privileged: true, path: "./setup.sh"
end
- setup.sh的配置
#/bin/sh
sudo yum install -y yum upgrade
sudo yum install -y net-tools
sudo yum install -y curl policycoreutils openssh-server openssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd
sudo yum install -y postfix
sudo systemctl enable postfix
sudo systemctl start postfix
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld
sudo yum install -y java-1.8.0-openjdk.x86_64
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
执行命令创建
#源码No.11的gitlab目录
vagrant up
更改安装源
新建 /etc/yum.repos.d/gitlab-ce.repo,内容为
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
- 执行命令
sudo yum makecache
sudo yum install gitlab-ce
- 安装成功!
- 运行下面的命令进行配置
sudo gitlab-ctl reconfigure
- 查看ip地址
ip a
登录网址
#登录,修改root密码。并登录 用户名是root,密码是刚设置的
http://172.28.128.3
修改主机的名字
sudo vi /etc/gitlab/gitlab.rb
#上边的修改保存后,需要执行下面的命令才可以生效
sudo gitlab-ctl reconfigure
关机后,重启gitlab的命令
gitlab-ctl restart
···
PS:gitlab安装基本就是这样也不是很复杂,主要是必须更改源,国内的墙太高太宽了。
![](http://upload-images.jianshu.io/upload_images/11223715-3407e1c7ac8d7935?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)