一、安装
1.docker安装gitlab
shell
sudo docker run -d \
-p 6080:80 -p 6022:22 \
--name gitlab \
--restart always \
-v /srv/gitlab/config:/etc/gitlab \
-v /srv/gitlab/logs:/var/log/gitlab \
-v /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
2.存储说明
- 存储应用数据:/srv/gitlab/data -> /var/opt/gitlab
- 存储日志数据:/srv/gitlab/logs -> /var/log/gitlab
- 存储 gitlab 配置文件:/srv/gitlab/config -> /etc/gitlab
3.Gitlab 配置
shell
docker exec -it gitlab /bin/bash
vi /etc/gitlab/gitlab.rb
docker restart gitlab
# 初始root密码在登录时不能手动设置,查看日志,输出在文件
# cat /etc/gitlab/initial_root_password
4.配置邮件
shell
# gitlab/config/gitlab.rb
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "gitlab@jsdfycwlkjyxg.wecom.work"
gitlab_rails['smtp_password'] = "EfiSJYPexHjVYE2S"
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['smtp_pool'] = false
docker exec -it gitlab /bin/bash
gitlab-ctl reconfigure
gitlab-ctl restart
gitlab-rails console
Notify.test_email('xxx@qq.com','gitlab邮箱通知测试','这是正文内容').deliver_now
遇到openSSL报错
启用如下配置
shell
gitlab_rails['smtp_openssl_verify_mode'] = 'none'
gitlab_rails['smtp_ca_path'] = "/etc/ssl/certs"
gitlab_rails['smtp_ca_file'] = "/etc/ssl/certs/ca-certificates.crt"
报错From必须与user一致
shell
gitlab_rails['gitlab_email_from'] = 'gitlab@jsdfycwlkjyxg.wecom.work'
gitlab_rails['gitlab_email_display_name'] = 'Gitlab'
邮件域名不对
shell
external_url 'https://git.xxx.com'
注意:设置external_url后,gitlab将自动将nginx开放到对应端口,https对应443,http对应80,需注意docker容器的端口映射。