目录
Gitlab
1. 使用docker部署gitlab
[root@master ~]# mkdir -p /data/gitlab/{config,logs,data}
编写docker-compose.yaml
[root@master ~]# mkdir gitlab
[root@master ~]# vim docker-compose.yaml
version: '3.3'
services:
gitlab:
hostname: gitlab
container_name: gitlab
restart: always
ports:
- "443:443"
- "80:80"
- "2222:22"
volumes:
- "/data/gitlab/config:/etc/gitlab"
- "/data/gitlab/logs:/var/log/gitlab"
- "/data/gitlab/data:/var/opt/gitlab"
# 这里的镜像自己改地址,目前国内不能直接访问dockerhub
image: gitlab/gitlab-ce
environment:
GITLAB_OMNIBUS_CONDIG: |
# 对外的地址
external_url 'http://gitlab.hcie.com'
gitlab_rails['gitlab_shell_ssh_port'] = 2222
# smtp是邮件,为了安全,gitlab创建账户之后不能直接设置密码,而是给邮箱发一个邮件,通过邮件里的链接去改密码,这里先让他启动,后面可以进web界面修改
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.hcie.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "xxxx"
gitlab_rails['smtp_domain'] = "smtp.hcie.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = false
gitlab_rails['smtp_tls'] = true
gitlab_rails['smtp_openssl_verify_mode'] = "peer"
gitlab_rails['gitlab_email_from'] = "[email protected]"
gitlab_rails['gitlab_email_display_name'] = "gitlab"
user["git_user_email"] = "[email protected]"
nginx["client_max_body_size"] = "0"
启动gitlab
[root@master gitlab]# docker-compose up -d
2. 登录gitlab
等待他启动之后我们查看默认密码
[root@master gitlab]# docker exec -it gitlab bash
root@gitlab:/# cat /etc/gitlab/initial_root_password
root@gitlab:/# cat /etc/gitlab/initial_root_password
# WARNING: This value is valid only in the following conditions
# 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
# 2. Password hasn't been changed manually, either via UI or via command line.
#
# If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
Password: JF6/7g7iH/iUX5hP2eJ4c6WVBYKe2sW1HZXu3o02HYA=
这里的就是密码了,只能使用24小时
- 默认用户名 root
2.1 修改语言为中文
将这里修改问中文
2.3 修改密码
因为临时密码只能使用24小时,所以得修改一下密码
修改完中文之后点击一下旁边的密码就可以修改了
-
当前密码就是那个临时密码
-
如果你的界面还是英文就刷新一下页面
3. 用户管理
3.1 创建用户
点进去之后就会有一个用户
- 这里的电子邮件地址不能乱填,之前就说过,他是会给这个邮件地址发送一封邮件,点击邮件里的链接才可以改密码的
- 但是我们之前的smtp服务都是瞎写的,邮件他肯定是发不出去的
- 我们可以先创建用户之后点击编辑,可以给他设置密码
4. 配置ssh拉取代码
如果使用http的方式去拉取代码的话,如果项目是私有的,那么每次都是需要登录的,但是在内部使用我们可以使用ssh的方式去拉取,这样就不用登录了
4.1 添加ssh密钥
-
将你自己的公钥放在这
-
公钥路径
[root@master test]# cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCbmEeD5QoRO+iDNIEANlLRU9N0vESKTEdjiUBrxaRk81qXeX4+SBC0fq5iVye9eUQ9QYP+ACOe1e/inGyPX4jAZVY6cNuCIkkIsPKrClkmQGovg/vE6QVIxiOzrFa38O+hGxuqtDVCRPAjTeGSdsU50ZlkvPlFf/R3Ja59BaxwPCTpomtF6Id1gvIdVmfNV1IsGaBjMOcNE24NVzKBwTUyR8MPw+or1uO5+5CGawCMJDQSsVl1KW5CASLcef5TJKq/Z9dDfKWTXEedPl+Ic6DgCCZ4Tyi372C2QUU3Vo78ugsdXW7zjWn/fH4j7vjYiO1eZqdXUxNyJMyB00ASF2ULQ9igAd/c3SvtomKPg+R94p40Nq/UpE8dlUzNFVCHFCEpBsoi8LPlcqmhhOpjv8Q2IESOn2pwZcl9a8T9txsdeCnX93k6my4iEE2ay3xddq/EJKRzbIAmRxjiqjixBtBaqR9qbud4JDgz1mHh6Gsk2Vdui0FslAtqXEFkDiT4s7M= root@master
4.2 测试拉取
[root@master workspace]# mkdir test1
[root@master test1]# git clone ssh://git@gitlab:2222/devops/app.git
Cloning into 'app'...
The authenticity of host '[gitlab]:2222 ([192.168.200.200]:2222)' can't be established.
ED25519 key fingerprint is SHA256:EB9YH9NMwMG5kxg7lYd8nyJdDwebSOiWH0zdXPHTmv0.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[gitlab]:2222' (ED25519) to the list of known hosts.
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (3/3), done.
[root@master test1]#
这个时候他就没有让我们输入密码了
注意配置主机的hosts解析
标签:gitlab,Gitlab,smtp,rails,密码,master,root,搭建 From: https://www.cnblogs.com/fsdstudy/p/18257239