首页 🙇‍♂️ DevOps

安装 Docker

yum install -y yum-utils device-mapper-persistent-data lvm2 
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 
yum makecache fast
yum install -y docker-ce-20.10.8-3.el7
systemctl start docker
systemctl enable docker

部署 Gitlab

mkdir /opt/gitlab
GITLAB_HOME=/opt/gitlab
## gitlab.iuskye.com 为访问域名,请自定义
docker run --detach \
    --hostname gitlab.iuskye.com \
    --publish 443:443 \
    --publish 80:80 \
    --publish 2222:22 \
    --name gitlab \
    --restart always \
    --volume $GITLAB_HOME/config:/etc/gitlab \
    --volume $GITLAB_HOME/logs:/var/log/gitlab \
    --volume $GITLAB_HOME/data:/var/opt/gitlab \
    gitlab/gitlab-ce:latest

修改配置

vim /opt/gitlab/config/gitlab.rb

## 修改默认ssh端口
gitlab_rails['gitlab_shell_ssh_port'] = 2222
## 配置邮件,这里以腾讯企业邮箱为例
gitlab_rails['smtp_enable'] = true
## 邮箱 SMTP 地址
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
## 配置端口
gitlab_rails['smtp_port'] = 465
## 配置邮箱地址
gitlab_rails['smtp_user_name'] = "abc@xyz.com"
## 配置邮箱密码
gitlab_rails['smtp_password'] = "abc123"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
## 配置邮箱地址
gitlab_rails['gitlab_email_from'] = 'abc@xyz.com'
gitlab_rails['smtp_domain'] = "exmail.qq.com"

重载服务

## 进入容器
docker exec -it gitlab bash
## 重载
gitlab-ctl reconfigure
## 验证,进入 console 后输入 ActionMailer::Base.delivery_method
gitlab-rails console
irb(main):001:0> ActionMailer::Base.delivery_method
## 输出 smtp 即可
=> :smtp
## 查看当前邮件发送配置
irb(main):002:0> ActionMailer::Base.smtp_settings
## 测试发送
irb(main):003:0> Notify.test_email('iuskye@iuskye.com','测试标题','测试内容').deliver_now

获取管理员账号密码

grep "Password" /opt/gitlab/config/initial_root_password

通过 Web 登录账号




文章评论

目录