docker-compose.yml
version: '3.6'
services:
web:
image: 'gitlab/gitlab-ce:15.9.1-ce.0'
restart: always
hostname: 'project.example.com'
container_name: gitlab
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://project.example.com'
# Add any other gitlab.rb configuration here, each on its own line
ports:
- '80:80'
- '443:443'
#- '22:22'
volumes:
- '/apps/gitlab/config:/etc/gitlab'
- '/apps/gitlab/logs:/var/log/gitlab'
- '/apps/gitlab/data:/var/opt/gitlab'
shm_size: '1g'
运行gitlab
运行gitlab
# docker-compose up -d
编辑gitlab.rb
# docker exec -it gitlab editor /etc/gitlab/gitlab.rb
启用SSL
修改gitlab.rb
# docker exec -it gitlab egrep -v "^$|^#" /etc/gitlab/gitlab.rb
external_url 'https://project.example.com'
nginx['enable'] = true
nginx['redirect_http_to_https'] = true
letsencrypt['enable'] = false
添加证书
# cp project.example.com.key project.example.com.crt /etc/gitlab/ssl/
SMTP 设置
修改gitlab.rb
gitlab_rails['smtp_pool'] = true
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'
gitlab_rails['smtp_domain'] = "exmail.qq.com"
测试SMTP
登录console
# docker exec -it gitlab gitlab-rails console
--------------------------------------------------------------------------------
Ruby: ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5) [x86_64-linux]
GitLab: 15.9.1 (de8f6619031) FOSS
GitLab Shell: 14.17.0
PostgreSQL: 13.8
------------------------------------------------------------[ booted in 46.23s ]
Loading production environment (Rails 6.1.7.2)
irb(main):001:0>
发送测试邮件
irb(main):001:0> Notify.test_email('1304995320@qq.com', 'Message Subject', 'Message Body').deliver_now
Delivered mail 64006bf333e4_36c488054440@project.stars-mine.com.mail (2793.5ms)
=> #<Mail::Message:295800, Multipart: false, Headers: <Date: Thu, 02 Mar 2023 09:27:15 +0000>, <From: GitLab <contact@hard-chain.cn>>, <Reply-To: GitLab <noreply@project.stars-mine.com>>, <To: 1304995320@qq.com>, <Message-ID: <64006bf333e4_36c488054440@project.stars-mine.com.mail>>, <Subject: Message Subject>, <Mime-Version: 1.0>, <Content-Type: text/html; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>, <Auto-Submitted: auto-generated>, <X-Auto-Response-Suppress: All>>
irb(main):002:0>
验证邮件
登录gitlab
默认用户名密码: /etc/gitlab/initial_root_password
参考文档
https://docs.gitlab.com/
标签:15.9,gitlab,smtp,rails,rb,docker,com From: https://www.cnblogs.com/wangguishe/p/17171785.html