docker-compose部署gitlab中文版

1. 配置docker-compose

這里用到了一個(gè)中文版的docker鏡像。https://hub.docker.com/r/twang2218/gitlab-ce-zh/

version: '3'
services:
    gitlab:
      image: 'twang2218/gitlab-ce-zh:9.4'
      restart: unless-stopped
      hostname: 'fantj.gitlab.top'
      environment:
        TZ: 'Asia/Shanghai'
        GITLAB_OMNIBUS_CONFIG: |
          external_url 'http://fantj.gitlab.top:9999'
          gitlab_rails['time_zone'] = 'Asia/Shanghai'
          # 需要配置到 gitlab.rb 中的配置可以在這里配置,每個(gè)配置一行,注意縮進(jìn)。
          # 比如下面的電子郵件的配置:
          # gitlab_rails['smtp_enable'] = true
          # gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
          # gitlab_rails['smtp_port'] = 465
          # gitlab_rails['smtp_user_name'] = "xxxx@xx.com"
          # gitlab_rails['smtp_password'] = "password"
          # gitlab_rails['smtp_authentication'] = "login"
          # gitlab_rails['smtp_enable_starttls_auto'] = true
          # gitlab_rails['smtp_tls'] = true
          # gitlab_rails['gitlab_email_from'] = 'xxxx@xx.com'
      ports:
        - '9999:9999'
          #- '443:443'
          #- '22:22'
      volumes:
        - /home/fantj/app/docker/compose/gitlab/config:/etc/gitlab
        - /home/fantj/app/docker/compose/gitlab/data:/var/opt/gitlab
        - /home/fantj/app/docker/compose/gitlab/logs:/var/log/gitlab

2. 配置hosts

[fantj@lalala gitlab]$ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1   www.xmind.net
127.0.0.1   fantj.gitlab.top

3. 創(chuàng)建目錄

[fantj@lalala gitlab]$ pwd
/home/fantj/app/docker/compose/gitlab
[fantj@lalala gitlab]$ ll
總用量 16
drwxrwxr-x  3 root    root  4096 9月  4 11:37 config
drwxr-xr-x 18 root    root  4096 9月  4 11:42 data
-rw-rw-r--  1 fantj   fantj 1286 9月  4 11:42 docker-compose.yml
drwxr-xr-x 19 polkitd fantj 4096 9月  4 11:38 logs

4. 啟動(dòng)

sudo docker-compose up -d
訪問http://fantj.gitlab.top:9999

5. 設(shè)置密碼并登錄

設(shè)置完密碼后,超級(jí)用戶賬號(hào)默認(rèn)是root。

登錄

6. 設(shè)置和使用

設(shè)置->設(shè)置
    設(shè)置ssh和http服務(wù)
    設(shè)置注冊服務(wù)開關(guān)
    設(shè)置項(xiàng)目限制
    設(shè)置頭像來源等等


新建項(xiàng)目

內(nèi)存修改

改之前先看看它有多吃內(nèi)存。。。

[fantj@lalala workspace]$ free -h
              total        used        free      shared  buff/cache   available
Mem:           15Gi       8.9Gi       246Mi       1.5Gi       6.4Gi       4.8Gi
Swap:         7.8Gi       4.0Mi       7.8Gi

修改方法有兩種,一種是進(jìn)入docker交互模式修改,一種是在docker-compose中設(shè)置參數(shù)。

注意:因?yàn)槲易隽薲ocker數(shù)據(jù)卷映射在本地的/home/fantj/app/docker/compose/gitlab/config目錄中,所以只需要修改config/gitlab.rb的參數(shù)即可。

1、減少進(jìn)程數(shù)

修改配置文件gitlab.rb中的worker_processes:

unicorn['worker_processes'] = 2

默認(rèn)是被注釋掉的,官方建議該值是CPU核心數(shù)加一,可以提高服務(wù)器的響應(yīng)速度,如果內(nèi)存只有4G,或者服務(wù)器上有其它業(yè)務(wù),就不要改了,以免內(nèi)存不足。另外,這個(gè)參數(shù)最小值是2,設(shè)為1,服務(wù)器可能會(huì)卡死。

2、減少數(shù)據(jù)庫緩存

默認(rèn)為256MB,可適當(dāng)改小

postgresql['shared_buffers'] = "256MB"
3、減少數(shù)據(jù)庫并發(fā)數(shù)

默認(rèn)為8,可適當(dāng)改小

postgresql['max_worker_processes'] = 8
4、減少sidekiq并發(fā)數(shù)

默認(rèn)是25,可適當(dāng)改小

sidekiq['concurrency'] = 25
重啟服務(wù)
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,544評(píng)論 19 139
  • 1. Docker ToolBox 非常方便實(shí)用的工具。 簡介: http://udn.yyuap.com/art...
    Hello75kg閱讀 15,783評(píng)論 6 23
  • 你一直承認(rèn)自詡是一條思想的小魚 驕傲 無比 可你生存的世界 水在干涸 你并沒有找到一條理想的水源 想去尋找大海呀...
    你要努力呀火星寶寶閱讀 672評(píng)論 2 0

友情鏈接更多精彩內(nèi)容