docker部署gitlab 郵件配置
阿新 • • 發佈:2018-11-30
docker gitlib搭建
基礎環境準備
安裝docker
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce -y
啟動docker
systemctl enable docker
systemctl start docker
docker 啟動gitlab
啟動gitlab映象
注意:gitlab進行啟動對映的埠可能和宿主機衝突,導致映象無法啟動,建議修改宿主機的埠。(gitlab映象ssh埠需要提供git 程式碼下載)
docker run --detach \ --hostname gitlab.example.com \ --publish 443:443 --publish 80:80 --publish 22:22 \ --name gitlab \ --restart always \ --volume /srv/gitlab/config:/etc/gitlab \ --volume /srv/gitlab/logs:/var/log/gitlab \ --volume /srv/gitlab/data:/var/opt/gitlab \ gitlab/gitlab-ce:latest
檢視gitlab映象狀態
# 檢視執行容器列表
docker ps
# 檢視容器執行日誌
docker logs -f CONTAINER_ID
修改gitlab配置檔案
配置檔案被對映到了本地的目錄下。--volume /srv/gitlab/config:/etc/gitlab
,修改vim /srv/gitlab/config/gitlab.rb
新增如下配置。
## GitLab URL
external_url 'http://gitlab.test.domain.com:8888'
### Email Settings
gitlab_rails['gitlab_email_enabled' ] = true
gitlab_rails['gitlab_email_from'] = '[email protected]'
gitlab_rails['gitlab_email_display_name'] = 'gitlab admin'
gitlab_rails['gitlab_email_reply_to'] = '[email protected]'
gitlab_rails['gitlab_email_subject_suffix'] = '[gitlab]'
# smtp 服務配置
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.heleicool.cn"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "heleicool"
gitlab_rails['smtp_domain'] = "heleicool.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
測試郵件傳送
gitlab-rails console production
# 確保method為smtp
> ActionMailer::Base.delivery_method
# 確認配置
> ActionMailer::Base.smtp_settings
# 測試傳送郵件
> Notify.test_email('[email protected]', 'Message Subject', 'Message Body').deliver_now
最後
使用root登入,進行主頁修改。