「GitLab」:修訂間差異

出自Gea-Suan Lin's Wiki
跳至導覽 跳至搜尋
本頁面具有訪問限制。如果您看見此訊息,這代表您沒有訪問本頁面的權限。
 
(未顯示同一使用者於中間所作的 36 次修訂)
行 1: 行 1:
'''GitLab'''是一套以[[Git]]為中心而發展出來的軟體。
'''GitLab'''是一套以[[Git]]為中心而發展出來的軟體。
== 簡介 ==
GitLab算是目前功能性與社群數量都比較成熟的方案。


== 安裝 ==
== 安裝 ==


 官方建議 記憶體最少4 GB 需要外加4 GB的Swap ,建議為8 GB<ref>{{Cite web |url=https://docs.gitlab.com/ee/install/requirements.html |title=Requirements |accessdate=2019-12-10}}</ref>。
 官方 建議 服務500人 )<ref>{{Cite web |url=https://docs.gitlab.com/ee/install/requirements.html |title=Requirements |accessdate=2023-03-08}}</ref>
 
* 4 CPU cores
* 4 GB RAM
* 2 GB Swap
 
實際測試發現剛裝完大約吃1.5 GB的記憶體,一個人自己用之後會到3 GB左右


 這邊介紹的是[[Ubuntu]]下的安裝過程<ref>{{Cite web |url=https://about.gitlab.com/install/?version=ce#ubuntu |title=GitLab Installation |accessdate=2019-12-10}}</ref>:
 這邊介紹的是[[Ubuntu]]下的安裝過程<ref>{{Cite web |url=https://about.gitlab.com/install/?version=ce#ubuntu |title=GitLab Installation |accessdate=2019-12-10}}</ref>:
行 10: 行 20:
sudo apt install -y ca-certificates curl openssh-server postfix
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
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo EXTERNAL_URL="https://gitlab.example.com" apt-get install gitlab-ce
sudo EXTERNAL_URL="https://gitlab.example.com" apt install gitlab-ce
</syntaxhighlight>
</syntaxhighlight>
最近的版本可能會需要處理安裝時[[Let's Encrypt]]憑證申請失敗的相關的問題<ref>{{Cite web |url=https://gitlab.com/gitlab-org/gitlab/issues/38255 |title=Unable to renew letsencrypt certificate anymore |accessdate=2019-12-18}}</ref>。


== 移除 ==
== 移除 ==
行 18: 行 30:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sudo gitlab-ctl uninstall
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
sudo gitlab-ctl cleanse
</syntaxhighlight>
sudo gitlab-ctl remove-accounts
 
sudo apt purge gitlab-ce
== 設定 ==
sudo rm -rf /etc/gitlab /opt/gitlab /var/log/gitlab /var/opt/gitlab
 
=== 帳號 ===
 
* 安裝完後console會出現指示初始密碼,目前的版本會在<code>/etc/gitlab/initial_root_password</codE>。
* 通常會關閉註冊(在網頁界面上就可以關閉)。
* 使用LDAP認證的設定需要透過<code>/etc/gitlab/gitlab.rb</code>修改,使用LDAPS的需要改設定使用<code>port: 636</code>與<code>encryption: 'simple_tls'</code>:
<syntaxhighlight lang="ruby">
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
</syntaxhighlight>
 
=== 記錄檔 ===
 
最容易爆掉的是[[Prometheus]]的[[TSDB]]資料<ref>{{Cite web |url=https://forum.gitlab.com/t/clear-up-postges-prometheus-data/38216 |title=Clear up Postges / Prometheus data |accessdate=2020-08-03 |date=2020-05-29 |language=en}}</ref>,這點可以設定<code>/etc/gitlab/gitlab.rb</code>內的<code>prometheus['flags']</code>限縮大小:
 
<syntaxhighlight lang="ruby">
prometheus['flags'] = {
  'storage.tsdb.path' => "/var/opt/gitlab/prometheus/data",
  'storage.tsdb.retention.time' => "15d",
  'config.file' => "/var/opt/gitlab/prometheus/prometheus.yml",
}
</syntaxhighlight>
 
=== 自己的nginx ===
 
官方有文件說明如何修改<ref>{{Cite web| url=https://docs.gitlab.com/omnibus/settings/nginx.html#using-a-non-bundled-web-server| title=Using a non-bundled web-server |language=en |accessdate=2021-06-24}}</ref>,先從<code>/etc/gitlab/gitlab.rb</code>裡關閉[[nginx]]相關設定。找到各自對應的區塊加上對應的設定:
 
<syntaxhighlight lang="ruby">
nginx['enable'] = false
web_server['external_users'] = ['www-data']
gitlab_rails['trusted_proxies'] = [ '127.0.0.0/8' ]
</syntaxhighlight>
 
接下來讓設定生效:
 
<syntaxhighlight lang="bash">
sudo gitlab-ctl reconfigure
</syntaxhighlight>
</syntaxhighlight>
後續就可以設定自己的nginx了。
== 常用指令 ==
重新讀取設定檔並且更新環境:
<syntaxhighlight lang="bash">
sudo gitlab-ctl reconfigure
</syntaxhighlight>
更新[[Let's Encrypt]]的憑證:
<syntaxhighlight lang="bash">
sudo gitlab-ctl renew-le-certs
</syntaxhighlight>
== 相關連結 ==
* [[GitLab/Runner]]


== 參考資料 ==
== 參考資料 ==

於 2023年5月26日 (五) 13:30 的最新修訂

GitLab是一套以Git為中心而發展出來的軟體。

簡介

GitLab算是目前功能性與社群數量都比較成熟的方案。

安裝

官方的建議是(服務500人)[1]

  • 4 CPU cores
  • 4 GB RAM
  • 2 GB Swap

實際測試發現剛裝完大約吃1.5 GB的記憶體,一個人自己用之後會到3 GB左右。

這邊介紹的是Ubuntu下的安裝過程[2]

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: 636encryption: '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

記錄檔

最容易爆掉的是PrometheusTSDB資料[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

相關連結

參考資料

外部連結