docker_gitlab搭建
这里使用 docker-compose.yml 的方式部署在虚拟机(ip:192.168.74.128)上部署的把gitlab官方的镜像拉下来wilker@ubuntu:~/Desktop/a_gitlab$ docker search gitlab # 搜一下 gitlab,基本第一个就是官方的NAMEDESC
这里使用 docker-compose.yml 的方式部署
在虚拟机(ip:192.168.74.128)上部署的
之前有过一篇也是gitlab搭建 在CentOS 7上安装GitLab
部署gitlab
把gitlab官方的镜像拉下来
wilker@ubuntu:~/Desktop/a_gitlab$ docker search gitlab # 搜一下 gitlab,基本第一个就是官方的 NAME DESCRIPTION STARS OFFICIAL AUTOMATED gitlab/gitlab-ce GitLab Community Edition docker image base... 1234 [OK] sameersbn/gitlab Dockerized gitlab web server 910 [OK] wilker@ubuntu:~/Desktop/a_gitlab$ docker pull gitlab/gitlab-ce # 拉下来 Using default tag: latest latest: Pulling from gitlab/gitlab-ce
在宿主中新建几个目录,然 gitlab 容器 挂载,存放 数据 及 配置
wilker@ubuntu:~/Desktop/a_gitlab$ sudo mkdir /opt/gitlab wilker@ubuntu:~/Desktop/a_gitlab$ sudo mkdir /opt/gitlab/config wilker@ubuntu:~/Desktop/a_gitlab$ sudo mkdir /opt/gitlab/log wilker@ubuntu:~/Desktop/a_gitlab$ sudo mkdir /opt/gitlab/data
编写一个 docker-compose.yml 文件
version: '2' services: gitlab: image: 'gitlab/gitlab-ce:latest' container_name: my_gitlab restart: always hostname: 'gitlab.example.com' environment: GITLAB_OMNIBUS_CONFIG: | external_url 'http://localhost' # Add any other gitlab.rb configuration here, each on its own line ports: - '80:80' - '22:22' volumes: - '/opt/gitlab/config:/etc/gitlab' - '/opt/gitlab/logs:/var/log/gitlab' - '/opt/gitlab/data:/var/opt/gitlab'
部署
wilker@ubuntu:~/Desktop/a_gitlab$ docker-compose up -d # 部署 Creating my_gitlab wilker@ubuntu:~/Desktop/a_gitlab$ docker-compose ps # 查看一下 Name Command State Ports <hr /> my_gitlab /assets/wrapper Up 0.0.0.0:22->22/tcp, 443/tcp, 0.0.0.0:80->80/tcp
然后要等上7、8秒左右,请求浏览器
http://localhost
才有反应,默认页面是设置 root 用户密码的界面设置好直接用来登录
然后上传 ssh 公钥
新建一个工程,在 物理机 上通过 ssh pull 下来。
如果添加了dns域名映射,则看 添加自定义域名 , 没有则看下一步
复制下来的 git 连接需要修改一下
git@localhost:root/test_proj.git # 修改为,改成虚拟机的ip git@192.168.74.128:root/test_proj.git
$ git clone git@192.168.74.128:root/test_proj.git # 然后就clone下来了 Cloning into 'test_proj'... remote: Counting objects: 3, done. remote: Total 3 (delta 0), reused 0 (delta 0) Receiving objects: 100% (3/3), done.
ok, done
添加自定义域名
做个内网的dns服务器,参考 ubuntu_内网dns服务器搭建.md , 添加一个域名 wilker.com 解析到 ip:192.168.74.128
修改配置文件 (宿主里) /opt/gitlab/config/gitlab.rb
wilker@ubuntu:~/Desktop/a_gitlab$ sudo vi /opt/gitlab/config/gitlab.rb # 取消这行注释并制定域名 external_url 'http://wilker.com'
重启 gitlab
wilker@ubuntu:~/Desktop/a_gitlab$ docker restart my_gitlab
就可以复制直接 clone 下来了
$ git clone git@wilker.com:root/test_proj.git Cloning into 'test_proj'... remote: Counting objects: 3, done. remote: Total 3 (delta 0), reused 0 (delta 0) Receiving objects: 100% (3/3), done.
邮件通知
以 qq 邮箱为例,其他差不多,其实配置差不多和 redmine 中的 邮件通知配置 差不多,参照 docker_redmine搭建.md
修改配置文件 : /etc/gitlab/gitlab.rb
gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.qq.com" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "364105996@qq.com" gitlab_rails['smtp_password'] = "auth_code" # 邮箱授权码,而不是qq密码 gitlab_rails['smtp_domain'] = "qq.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_ssl'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'none' gitlab_rails['gitlab_email_from'] = "364105996@qq.com" gitlab_rails['gitlab_email_reply_to'] = '364105996@qq.com' gitlab_rails['gitlab_email_display_name'] = 'GitLab-Robot'
测试发送
root@gitlab:/# gitlab-rails console > Notify.test_email('553972977@qq.com', 'Message Subject', 'Message Body').deliver_now #测试发送邮件 # 发送提示 Notify#test_email: processed outbound mail in 305.8ms Sent mail to 553972977@qq.com (854.5ms) Date: Wed, 19 Jul 2017 03:36:34 +0000 From: GitLab-Robot <364105996@qq.com> Reply-To: GitLab-Robot <364105996@qq.com> To: 553972977@qq.com
如果成功发送,会有以下提示
# 发送成功提示 => #<Mail::Message:70141395443160, Multipart: false, Headers: <Date: Wed, 19 Jul 2017 03:36:34 +0000>, <From: GitLab-Robot <364105996@qq.com>>, <Reply-To: GitLab-Robot <364105996@qq.com>>, <To: 553972977@qq.com>, <Message-ID: <596ed3c25fb6_19523fcb189c711035918@gitlab.example.com.mail>>, <Subject: Message Subject>, <Mime-Version
此时也有qq弹窗提示
踩坑记录
- 如果报错:
Net::ReadTimeout
,可能是下面几个没有配置
gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_ssl'] = true
- 如果报错:
关闭 avatar 头像请求
- 默认开启了 avatar,会去请求 https://www.gravatar.com/ 造成打开页面速度极慢,需要关掉,在页面 http://ip:port/admin/application_settings 中, Account and Limit Settings -> Gravatar enabled 取消勾选,然后 点击 Save 保存设置即可
参考资料
更多推荐
所有评论(0)