Gitlab搭建

简介: Gitlab搭建

目录

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_CONFIG: |
        # 对外的地址
        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'] = "notify@hcie.com"
        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'] = "notify@hcie.com"
        gitlab_rails['gitlab_email_display_name'] = "gitlab"
        user["git_user_email"] = "notify@hcie.com"
        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解析

本文来自博客园,作者:FuShudi,转载请注明原文链接:https://www.cnblogs.com/fsdstudy/p/18257239

分类: Euler / HCIE / k8s , Euler

目录
相关文章
|
Ubuntu 应用服务中间件 项目管理
部署gitlab详解
部署gitlab详解
部署gitlab详解
|
1月前
|
安全 Ubuntu 网络协议
gitlab安装部署
对于Ubuntu 20.04和22.04,`arm64`架构的软件包也可用,在使用GitLab仓库安装时会自动选择这些包。简介详细介绍了在Ubuntu系统上安装和配置GitLab的步骤,包括安装依赖项、Postfix邮件服务设置、添加GitLab软件包仓库、安装GitLab软件包以及浏览主机名登录。还提供了通信偏好设置指南,确保用户能接收重要安全更新。安装完成后,建议进一步配置认证选项和注册限制。
58 5
|
2月前
|
Shell Docker 容器
GitlabCI学习笔记之一:安装Gitlab和GitLabRunner
GitlabCI学习笔记之一:安装Gitlab和GitLabRunner
|
2月前
|
jenkins 持续交付 数据安全/隐私保护
GitLab——如何快速部署GitLab仓库
GitLab——如何快速部署GitLab仓库
32 0
|
运维 程序员 测试技术
Gitlab上手指南(二)|大多数企业为什么会使用Gitlab,Gitlab工作流是什么样的?
GitLab拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库
535 0
|
网络安全 开发工具 数据安全/隐私保护
gitlab在服务器上的安装与配置-自己搭建一个gitlab服务器
gitlab在服务器上的安装与配置-自己搭建一个gitlab服务器
1143 0
|
开发工具 git
Gitlab 基础配置(2)
Gitlab 基础配置(2)
Gitlab 基础配置(2)
|
数据安全/隐私保护
Gitlab 基础配置(1)
Gitlab 基础配置(1)
Gitlab 基础配置(1)
|
域名解析 Linux 网络安全
GitLab的安装部署
GitLab的安装部署
GitLab的安装部署
|
缓存 Linux 开发工具
部署Gitlab(二)
部署Gitlab(二)