GitLab
鑒于現(xiàn)在的大部分公司都會使用Gitlab作為自己的代碼倉庫,有必要搭建起來玩一玩。以下完全是自己的實踐結果,并已應用于20~30人團隊的使用中,目前系統(tǒng)運行比價穩(wěn)定,就是有點吃內存。
下載(docker)
查詢docker鏡像gitlab-ce
gitlab-ce是它的社區(qū)版
[root@localhost ~]# docker search gitlab-ce
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
rapidfort/gitlab-ce 12
drud/gitlab-ce 18
gitlab/gitlab-ce GitLab Community Edition docker image based … 4043 [OK]
下載鏡像
下載鏡像gitlab/gitlab-ce
latest: Pulling from gitlab/gitlab-ce
7b1a6ab2e44d: Pull complete
6c37b8f20a77: Pull complete
f50912690f18: Pull complete
bb6bfd78fa06: Pull complete
2c03ae575fcd: Pull complete
839c111a7d43: Pull complete
4989fee924bc: Pull complete
666a7fb30a46: Downloading [=================================> ] 662.1MB/995.5MB

啟動安裝docker容器
創(chuàng)建gitlab文件夾
[root@localhost softwares]# mkdir gitlab
[root@localhost softwares]# ll
總用量 0
drwxr-xr-x. 2 root root 6 10月 28 10:24 gitlab
drwxr-xr-x. 3 root root 60 9月 23 23:41 jdk
drwxr-xr-x. 4 root root 30 9月 24 23:44 mysql
drwxr-xr-x. 5 root root 109 9月 24 17:44 nexus
drwxr-xr-x. 4 root root 42 10月 22 22:17 redis
[root@localhost softwares]# pwd
/usr/local/softwares
創(chuàng)建config,logs,data文件夾
[root@localhost gitlab]# mkdir config logs data
[root@localhost gitlab]# tree
.
├── config
├── data
└── logs
創(chuàng)建運行容器
docker run -it \
--hostname wnhz-gitlab.com \
--name gitlab \
-p 443:443 -p 80:80 -p 23:22 \
--network wn_docker_net \
--ip 172.18.12.50 \
-v /usr/local/softwares/gitlab/config:/etc/gitlab \
-v /usr/local/softwares/gitlab/logs:/var/log/gitlab \
-v /usr/local/softwares/gitlab/data:/var/opt/gitlab \
-d gitlab/gitlab-ce
[root@localhost gitlab]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cf0f38c6f0a4 gitlab/gitlab-ce "/assets/wrapper" 4 seconds ago Up 3 seconds (health: starting) 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:23->22/tcp, :::23->22/tcp gitlab
gitlab配置
訪問http://192.168.198.128/ linux主機地址
設置用戶名密碼
命令行:docker exec -it gitlab bash 進入容器
輸入命令行 gitlab-rails console
[root@localhost gitlab]# docker exec -it gitlab bash
root@cf0f38c6f0a4:/# gitlab-rails console

輸入用戶名密碼存儲
user=User.find_by_username ‘root’
user.password=‘88888888’
user.save!
Loading production environment (Rails 6.1.4.1)
irb(main):001:0> user=User.find_by_username 'root'
=> #<User id:1 @root>
irb(main):004:0> user.password='88888888'
=> "88888888"
irb(main):005:0> user.save!
=> true
登錄
使用設置的用戶名,密碼登錄

Gitlab設置
關閉自動注冊功能
- Menu->Admin

-
Settings->Geneal->Sign-up restrictions
-
禁止注冊
創(chuàng)建用戶User
在Admin下點擊Admin Area --> Users
創(chuàng)建用戶: New user
編輯用戶信息
給指定用戶添加密碼
使用新用戶登錄

第一次登錄強制要求修改密碼

修改個人信息


優(yōu)化gitlab占用內存
進入gitlab容器
使用root用戶登錄
docker exec -it gitlab bash
進入etc/gitlab文件夾
修改gitlab.rb文件
tips: 如果容器中不能使用vim命令,使用 apt-get update , apt-get install vim安裝
-
gitlab_rails[‘env’]
597 gitlab_rails['env'] = { 598 'MALLOC_CONF' => 'dirty_decay_ms:1000,muzzy_decay_ms:1000' 599 # "SKIP" => "db,uploads,repositories,builds,artifacts,lfs,registry,pages" 600 }
-
[‘worker_processes’]
禁用 puma cluster 模式
974 puma['worker_timeout'] = 60 975 puma['worker_processes'] = 0
-
sidekiq
1018 sidekiq['max_concurrency'] = 10
重啟容器
- 配置生效
在容器中輸入: gitlab-ctl reconfigure
root@192:/etc/gitlab# gitlab-ctl reconfigure
- 重啟容器
在容器內輸入:gitlab-ctl restart 重啟容器。
root@192:/etc/gitlab# gitlab-ctl restart
查詢gitlab的內存占用
docker stats gitlab
idea使用gitlab
在gitLab上創(chuàng)建倉庫
idea使用gitlab錯誤
error: unable to read askpass response from ‘C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2021.3\tmp\intellij-git-askpass-local.sh’
解決方案: 修改項目隱藏.git下的config文件,添加gitlab用戶名密碼
rom ‘C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2021.3\tmp\intellij-git-askpass-local.sh’
[外鏈圖片轉存中…(img-WGsPnXox-1703410195225)]
解決方案: 修改項目隱藏.git下的config文件,添加gitlab用戶名密碼
[外鏈圖片轉存中…(img-aedxGTVv-1703410195226)]文章來源:http://www.zghlxwxcb.cn/news/detail-800115.html
[外鏈圖片轉存中…(img-1lhcN67n-1703410195226)]文章來源地址http://www.zghlxwxcb.cn/news/detail-800115.html
到了這里,關于搭建自己的gitlab服務器(Docker版)的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!