最近有需求在Mac環境中,使用Docker建置Gitlab的開發環境與CI /CD , 所以記錄一下相關的步驟與細節,Gitlab是一個用Ruby on Rails 開發的開源項目,可以通過web 界面進行專案管理與測試。
使用Docker 佈署可以很容易進行安裝Gitlab與版本管理。
安裝Docker Desktop
- 下載Docker.dmg (https://docs.docker.com/docker-for-mac/install/)
- 點擊Docker.dmg 將Docker.app 拖移到Applications 中

- 點擊Docker.app進行安裝
啟動後會提示您使用系統密碼授權Docker.app。 需要特權訪問才能安裝網絡組件和Docker應用程序的鏈接。

頂部狀態欄中的Docker菜單表示Docker Desktop正在運行,並且可以從終端進行訪問。
如果您剛剛安裝了該應用程序,則還會收到一條消息,其中包含建議的後續步驟以及指向文檔的鏈接。 單擊Docker menu以消除此彈出通知。
- 開啟Teminal 確認docker 指令可以正常
$ docker -v

下載Gitlab image
$ docker pull gitlab/gitlab-ce
建立Gitlab Container
$ sudo docker run -d \
--hostname xxxx.xxxx.xx \
--name gitlab \
--restart always \
--publish 30001:22 --publish 30000:80 --publish 30002:443 \
--volume ~/gitlab/data:/var/opt/gitlab \
--volume ~/gitlab/logs:/var/log/gitlab \
--volume ~/gitlab/config:/etc/gitlab \
gitlab/gitlab-ce
- hostname 建立gitlab 的位置可使用domain or ip
- name container 名稱
- restart 設定為docker 服務啟動後自動重啟
- publish 將主機的30000, 30001, 30002 對應到 80, 22, 443
- volume 將gitlab 的檔案對應到實體主機的路徑,container 刪除後重建與更新後不影響系統資料
修改gitlab.rb 文件
因為已經有把gitlab.rb 文件對應到 ~/gitlab/config
$ vi ~/gitlab/config/gitlab.rb
修改的內容如下:
- external_url ‘http://hostname:30000‘
- gitlab_rails[‘gitlab_ssh_host’] = ‘hostname’
- gitlab_rails[‘gitlab_shell_ssh_port’] = 30001
- nginx[‘listen_port’] = 80
修改email 的配置
一樣在gitlab.rb 中增加smtp的配置
gitlab_rails[‘gitlab_email_from’] = “xxxx@163.com”
gitlab_rails[‘gitlab_email_reply_to’] = ‘xxxx@163.com‘
gitlab_rails[‘smtp_enable’] = true
gitlab_rails[‘smtp_address’] = “smtp.163.com“
gitlab_rails[‘smtp_port’] = 465
gitlab_rails[‘smtp_user_name’] = “xxxx@163.com”
gitlab_rails[‘smtp_password’] = “xxxxpassword” gitlab_rails[‘smtp_domain’] = “163.com” gitlab_rails[‘smtp_authentication’] = “login” gitlab_rails[‘smtp_enable_starttls_auto’] = true
gitlab_rails[‘smtp_tls’] =true gitlab_rails[‘smtp_openssl_verify_mode’] = “peer”
重啟gitlab service
$ sudo docker exec -it gitlab /bin/bash
$ gitlab-ctl reconfigure
I visit daily a few blogs and blogs to read articles, bbut thiis webpage presentys feature bbased
posts.
Wonderful blog! I found it while searching onn Yahoo News. Do yyou
hage any tips on how too get losted in Yahuoo News?
I’ve been trying for a while but I nefer seerm tto get there!
Thanks
I have bewn browsing online mpre than three hours
today, yet I ndver found aany interesting artice likee yours.
It’s pretty worth enough for me. Personally, if all website ownrs aand bloggerss maxe good contrnt as yoou did, the internet
will bee much more useful thgan ecer before.
Thaat is vrry attention-grabbing, You’re an eccessively
skilled blogger. I’ve joined youyr rss feed annd look aheqd too looiking for more oof yourr fantastic post.
Also, I’ve shared ypur website in myy social networks
Wow, sulerb blog format! Hoow long have you ever been ruinning a blog for?
yoou make running a bllog glabce easy. The overall glancce of your site
is great, as smartly aas thhe content!
Hi tto every one, as I aam truly eager of rsading this webpage’s
post tto bbe updated daily. It contains nicfe data.
I was curipus if yoou eer considerd hanging thhe psge layout of yoyr blog?
Its very wel written; I loove what youve goot to say.
But maybe yoou could a lottle mmore inn thee wayy oof ckntent so peeople coulod comnect wih it better.
Youve got an awfyl llot of tedt forr onbly having one oor twwo pictures.
Maybe you cokuld space iit out better?
Awwsome blog! Is your thee custom made oor did you dowenload iit from somewhere?
A theme likke yors with a few simple weeks woould rally mmake
my blog jump out. Please llet me know where yyou got your theme.
Manyy thanks
I’m truloy enjoying thee design and layyout of your blog.
It’s a ery easy on thhe eyes which makes it much more pleasant for me to
clme here annd visit more often. Did yoou hiore out a designer to create yolur theme?
Supesrb work!
I aam regularr visitor, hoow aare yoou everybody? This paragraph
posted at this web page is really pleasant.
If some oone neeeds too be updated with latest technologies therefore hhe must
bee go to seee this websute andd be up tto datte everyday.
I have been surfing onine more thsn 2 hohrs today, yett
I never found anny interestinhg aarticle like yours. It’s pretty worth enouvh
for me. Personally, if all website owners aand bloggers
made good content as you did,the net will be muc more useful than ever before.
Hi, I wish for to subscribe foor this webpage tto oobtain newest updates,
thus where can i do it please help.
Woww that wwas odd. I just wrote an icredibly loong commwnt butt aftter
I clicked suubmit my conment didn’t appear. Grrrr…
well I’m not writing alll thaat over again. Anyhow, just wanted to say excellent blog!
Helloo to evry one, because I am in faact keen of reading tjis blog’s post
to be updated daily. It carries nice stuff.
Goood day! Do yyou kniw iff they make anny plugins
to assist with SEO? I’m tryijg to geet my log to rnk for soe targeted keyords buut
I’m not seeung vwry good results. If you knoow of any plesase share.
Cheers!
Hi to all, it’s trul a fasstidious ffor me too
pay a qick viisit thius site, itt incluides hewlpful Information.
If yyou wwould like to imprrove you nowledge simly kee visiting this web siye annd bbe upldated with the
hottest gossipp posted here.
Pleas llet mme know iff you’re looking ffor a artihle wrtiter ffor your site.
Yoou haqve some really grewat articles aand Ibeslieve I woulkd be a good asset.
If you ever want too take some of thee losd off, I’d absolutely
love to writte some conteht forr yoiur bloog in exxchange ffor a linmk back to
mine. Pleaase blast me aan e-mail iif interested. Manny thanks!
Howdy vwry nice site!! Man .. Beautiful .. Amaxing .. I will bookomark
your ite and take the feds additionally? Iam glaqd tto eek oout a lott of helpful
infirmation right here withhin thhe submit, we waqnt develop extda techniques oon this regard, thank
you for sharing. . . . . .
I’m currious to fijd outt what blog system you’re using?
I’m having somje minor security isssues with myy latest sitge andd I’d
lie too find something moe safe. Do you have any recommendations?
Grewat work! Thhis is the type oof ibfo thzt aare ment to be shared across the net.
Dsgrace onn Google for no loinger positioning this
post higher! Come on ovcer and consult wit mmy site . Thaznk yoou =)
Greetings! Quick querstion that’s totlly off topic.
Do you kno how to mazke your site mobille
friendly? My web ste looks weiord when vieeing from my iphone.
I’m tryng to find a thesme or plgin that might be able to
redolve thyis problem. If yoou haave any
recommendations, pleazse share. Appreciate it!
Thabks for a marfelous posting! I truly enjoyed reading it, you
ccan be a grreat author.I wkll esure that I bookmark
your bkog andd definitely will cpme bback
very soon. I waznt tto encourage continu yor greeat
posts, have a nie weekend!
Superb blpog yoou have here butt I was curiouss if you knew of anyy forums
tnat covver thhe same topics discussed iin this article? I’d really loge to bee a part oof community wyere I ccan get feedback
from othewr knowledgeable people tuat shazre thee sane interest.
If youu have aany recommendations, please lett me know.
Appfeciate it!