BoyChai's Blog - 代码仓库 https://blog.boychai.xyz/index.php/tag/%E4%BB%A3%E7%A0%81%E4%BB%93%E5%BA%93/ zh-CN Sat, 28 May 2022 11:23:00 +0000 Sat, 28 May 2022 11:23:00 +0000 GitLab-代码仓库(部署安装) https://blog.boychai.xyz/index.php/archives/12/ https://blog.boychai.xyz/index.php/archives/12/ Sat, 28 May 2022 11:23:00 +0000 BoyChai 官方文档

官方文档

系统直接安装的方式

系统环境

CentOS7,4核CPU和4G内存,selinux和防火墙全部关闭

官方推荐最小配置为4核CPU和4G内存,GitLab很吃内存,太低可能部署不起来

安装

sudo yum install -y curl policycoreutils-python openssh-server perl   //安装前置依赖软件
sudo systemctl enable sshd  //设置开机自启 
sudo systemctl start sshd   //开启服务
curl -fsSL https://packages.gitlab.cn/repository/raw/scripts/setup.sh | /bin/bash  //配置yum源
sudo EXTERNAL_URL="http://gitlab.host.com" yum install -y gitlab-jh  //设置访问地址之后安装GitLab

安装好之后会出先一些备注信息,如下图

gitlab_01

使用Docker的方式

系统环境

CentOS7,4核CPU和4G内存,selinux和防火墙全部关闭

官方推荐最小配置为4核CPU和4G内存,GitLab很吃内存,太低可能部署不起来

docker版本为 20.10.16

docker-compose版本为 v2.5.0

安装

系统变量配置

在安装之前需要配置一个系统环境,用来存储GitLab安装时、运行时,产生的配置、日志文件。

export GITLAB_HOME=/srv/gitlab
本地位置容器位置存储内容
$GITLAB_HOME/data/var/opt/gitlab用于存储应用程序数据。
$GITLAB_HOME/logs/var/log/gitlab用于存储日志。
$GITLAB_HOME/config/etc/gitlab用于存储极狐GitLab 配置文件。

使用docker安装

sudo docker run --detach \
  --hostname gitlab.host.com \
  --publish 443:443 --publish 80:80 --publish 23: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 \
  --shm-size 256m \
  registry.gitlab.cn/omnibus/gitlab-jh:latest

其中--hostname需要替换成自己的域名。之后使用docker的方式安装下载好镜像启动之后容器会进行初始化,期间是访问不了的可以使用命令“sudo docker logs -f gitlab”来查看进度

使用docker-compose安装

docker-cmpose的yml文件内容为

version: '3.6'
services:
  web:
    image: 'registry.gitlab.cn/omnibus/gitlab-jh:latest'
    restart: always
    hostname: 'gitlab.host.com'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'https://gitlab.example.com'
        # Add any other gitlab.rb configuration here, each on its own line
    ports:
      - '80:80'
      - '443:443'
      - '23:22'
    volumes:
      - '$GITLAB_HOME/config:/etc/gitlab'
      - '$GITLAB_HOME/logs:/var/log/gitlab'
      - '$GITLAB_HOME/data:/var/opt/gitlab'
    shm_size: '256m'

启动命令: "docker-compose up -d"
其中hostname需要替换成自己的域名,之后使用docker安装的话下载好镜像启动之后容器会进行初始化,期间是访问不了的,如果想要查看进度需要查看docker-compose运行容器的名称之后使用
命令”docker logs -f [容器名称]“来看。

安装完成

此时访问配置好的域名即可访问,默认账号为root,密码存放在系统或者容器的/etc/gitlab/initial_root_password文件中,cat一下直接使用即可

gitlab_02

ps:容器密码文件存放在/srv/gitlab/config/initial_root_password文件中,全部的密码文件只会存在24小时,使用这个密码登录只后建议创建一个新的密码

]]>
0 https://blog.boychai.xyz/index.php/archives/12/#comments https://blog.boychai.xyz/index.php/feed/tag/%E4%BB%A3%E7%A0%81%E4%BB%93%E5%BA%93/