GitLab
跳转到导航
跳转到搜索
GitLab是一套以Git为中心而发展出来的软件。
简介
GitLab算是目前功能性与社群数量都比较成熟的方案。
安装
官方的建议是(服务500人)[1]:
- 4 CPU cores
- 4 GB RAM
- 2 GB Swap
实际测试发现刚装完大约吃1.5 GB的内存,一个人自己用之后会到3 GB左右。
sudo apt install -y ca-certificates curl openssh-server postfix
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo EXTERNAL_URL="https://gitlab.example.com" apt install gitlab-ce
最近的版本可能会需要处理安装时Let's Encrypt凭证申请失败的相关的问题[3]。
移除
移除需要多个步骤[4]:
sudo gitlab-ctl uninstall; sudo gitlab-ctl cleanse; sudo gitlab-ctl remove-accounts; sudo apt purge -y gitlab-ce; sudo rm -rf /etc/gitlab /opt/gitlab /var/log/gitlab /var/opt/gitlab
设定
账号
- 安装完后console会出现指示初始密码,目前的版本会在
/etc/gitlab/initial_root_password
。 - 通常会关闭注册(在网页界面上就可以关闭)。
- 使用LDAP认证的设定需要透过
/etc/gitlab/gitlab.rb
修改,使用LDAPS的需要改设定使用port: 636
与encryption: 'simple_tls'
:
gitlab_rails['ldap_enabled'] = true
gitlab_rails['prevent_ldap_sign_in'] = false
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
main:
label: 'LDAP'
host: 'ldap.example.com'
port: 389
uid: 'uid'
bind_dn: ''
password: ''
encryption: 'plain'
verify_certificates: true
smartcard_auth: false
active_directory: false
allow_username_or_email_login: true
lowercase_usernames: true
block_auto_created_users: false
base: 'ou=People,dc=example,dc=com'
user_filter: ''
attributes:
email: ['mail', 'email', 'userPrincipalName']
EOS
记录档
最容易爆掉的是Prometheus的TSDB资料[5],这点可以设定/etc/gitlab/gitlab.rb
内的prometheus['flags']
限缩大小:
prometheus['flags'] = {
'storage.tsdb.path' => "/var/opt/gitlab/prometheus/data",
'storage.tsdb.retention.time' => "15d",
'config.file' => "/var/opt/gitlab/prometheus/prometheus.yml",
}
自己的nginx
官方有文件说明如何修改[6],先从/etc/gitlab/gitlab.rb
里关闭nginx相关设定。找到各自对应的区块加上对应的设定:
nginx['enable'] = false
web_server['external_users'] = ['www-data']
gitlab_rails['trusted_proxies'] = [ '127.0.0.0/8' ]
接下来让设定生效:
sudo gitlab-ctl reconfigure
后续就可以设定自己的nginx了。
常用指令
重新读取设定档并且更新环境:
sudo gitlab-ctl reconfigure
更新Let's Encrypt的凭证:
sudo gitlab-ctl renew-le-certs
相关连结
参考资料
- ↑ Requirements. [2023-03-08].
- ↑ GitLab Installation. [2019-12-10].
- ↑ Unable to renew letsencrypt certificate anymore. [2019-12-18].
- ↑ Is it fine to remove the /opt/gitlab/ directory manually after removing the gitlab package from the system?. 2016-09-14 [2019-12-10].
- ↑ Clear up Postges / Prometheus data. 2020-05-29 [2020-08-03] (English).
- ↑ Using a non-bundled web-server. [2021-06-24] (English).
外部链接
- 官方网站 (英文)