当前位置:  首页>> 技术小册>> Redis零基础到实战

无论是github,还是gitee,使用他们作为远程仓库,有一个缺点,代码是保存在他们的服务器上的。
如果他们的服务出现宕机,将导致git远程仓库不可用。
同时,如果项目对于代码的安全性要求较高时,也会考虑自己搭建git服务器。


搭建gitlab:


安装文档:
https://docs.gitlab.com/ee/install/docker.html

1.搜索gitlab镜像:

  1. docker search gitlab-ce

拉取镜像:

  1. docker pull gitlab/gitlab-ce

2.设置gitlab的home目录:

  1. export GITLAB_HOME=/srv/gitlab

3.gitlab对应host的数据卷目录:

Local location Container location Usage
$GITLAB_HOME/data /var/opt/gitlab For storing application data.
$GITLAB_HOME/logs /var/log/gitlab For storing logs.
$GITLAB_HOME/config /etc/gitlab For storing the GitLab configuration files.

4.运行gitlab容器:

  1. sudo docker run --detach \
  2. --hostname 192.168.31.100 \
  3. --publish 443:443 --publish 80:80 --publish 2222:22 \
  4. --name gitlab \
  5. --restart always \
  6. --volume $GITLAB_HOME/config:/etc/gitlab \
  7. --volume $GITLAB_HOME/logs:/var/log/gitlab \
  8. --volume $GITLAB_HOME/data:/var/opt/gitlab \
  9. --shm-size 256m \
  10. gitlab/gitlab-ce:latest

5.重置密码:
登录到gitlab控制台
gitlab-rails console

重置用户密码

  1. user=User.where(id:1).first
  2. user.password='a12345678'
  3. user.password_confirmation='a12345678'
  4. user.save

6.登录gitlab.
输入gitlab地址:192.168.31.100

后面的操作和github一致。
1.添加id_rsa.pub
2.初始化仓库
(注意:下面这步操作的地址将http:// 改为git@,并用地址中的”/“替换为 “:”)

  1. git remote add origin http://192.168.31.100/gitlab-instance-43323dda/mygitlab.git

如何设置错了,使用如下命令重新设置:

  1. git remote set-url origin giturl

示例:

  1. git remote set-url origin git@192.168.31.100:gitlab-instance-43323dda/mygitlab.git

完善:
邮箱的配置、gitlab的配置等。


该分类下的相关小册推荐: