首页 技术 正文
技术 2022年11月15日
0 收藏 668 点赞 4,429 浏览 2967 个字

Gitlab

GitLab是由GitLabInc.开发,使用MIT许可证的基于网络Git仓库管理工具,且具有wiki和issue跟踪功能。使用Git作为代码管理工具,并在此基础上搭建起来的web服务。

  • 免费、开源
  • 功能强大
  • 分布式
  • Git flow
  • GitLab CI

基础docker 安装的地址:https://docs.gitlab.com/omnibus/docker/

  1. 拉取镜像

    # docker pull gitlab/gitlab-ce:latest
    # 官方版本是:gitlab/gitlab-ce:latest,为了提升速度我们这里使用阿里云的仓库
    docker pull registry.cn-hangzhou.aliyuncs.com/imooc/gitlab-ce:latest
    docker tag registry.cn-hangzhou.aliyuncs.com/imooc/gitlab-ce gitlab/gitlab-ce
  2. 运行GitLab容器

    sudo docker run --detach \
    --hostname gitlab.example.com \
    --env GITLAB_OMNIBUS_CONFIG="external_url 'http://my.domain.com/'; gitlab_rails['lfs_enabled'] = true;" \
    --publish : --publish : --publish : \
    --name gitlab \
    --restart always \
    --volume /srv/gitlab/config:/etc/gitlab \
    --volume /srv/gitlab/logs:/var/log/gitlab \
    --volume /srv/gitlab/data:/var/opt/gitlab \
    gitlab/gitlab-ce:latest
  3. 查看安装日志

    docker logs --follow gitlab
  4. 修改配置
    vim /srv/gitlab/config/gitlab.rbexternal_url 'http://47.111.84.191/'service docker restart
  5. 设置密码
    安装完成后登录80端口访问,进行设置登录密码,我这里设置 root Root123456 ,然后进行登录即可
    【ASP.NET Core分布式项目实战】(六)Gitlab安装

GitLab Runner注册和安装

安装

  1. 在系统中的某个位置创建一个文件夹,例如: C:\GitLab-Runner 。
  2. 下载x86amd64的二进制文件并将其放入您创建的文件夹中。将二进制文件重命名为 gitlab-runner.exe 。您可以按Bleeding Edge中的描述为每个可用版本下载二进制文件 – 下载任何其他标记版本
  3. 运行提升的命令提示符
    1. 按Windows键或单击开始按钮。
    2. 类型PowerShell
    3. 单击鼠标右键Windows PowerShell,然后选择Run as administrator
  4. 注册GitLab Runner
    获取Token:
    【ASP.NET Core分布式项目实战】(六)Gitlab安装
    # https://docs.gitlab.com/runner/register/index.html
    # -运行以下命令
    gitlab-runner.exe register# -输入您的GitLab实例URL
    http://47.111.84.191/# -输入您获得的Token
    # 在项目的 Settings->Pipelines中可以找到
    JGGzoYj_uQoxQVGjWnKn# -输入Runner的描述,您可以稍后在GitLab的UI中更改
    local-win# -输入与Runner关联的tags,您可以稍后在GitLab的UI中更改,可以不输入# -输入Runner执行程序:
    shell

    【ASP.NET Core分布式项目实战】(六)Gitlab安装

  5. 添加用户
    【ASP.NET Core分布式项目实战】(六)Gitlab安装

    【ASP.NET Core分布式项目实战】(六)Gitlab安装

  6. SSH 连接GitLab
    官方文档:https://docs.gitlab.com/ee/ssh/README.html如果 C:\Users\Administrator\.ssh 目录下有则可以使用已经存在的SSH key。
    生成SSH

    ssh-keygen -o -t rsa -b  -C "786744873@qq.com"

    【ASP.NET Core分布式项目实战】(六)Gitlab安装

  7. SSH 连接 22 端口
    正常情况下你已经可以通过git命令来连接我们部署的gitlab,但这里不一样的是我们把容器的 22端口映射到了 host的 23上,我们需要指定端口来进连接。

    ssh -p  git@47.111.84.191
    C:\Users\Administrator\.ssh>ssh -p  git@47.111.84.191
    The authenticity of host '[47.111.84.191]:23 ([47.111.84.191]:23)' can't be established.
    ECDSA key fingerprint is SHA256:DAQttfMOxIIiNqgt/QIvL6tv1pwgPax/fsnBprwZhN0.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '[47.111.84.191]:23' (ECDSA) to the list of known hosts.
    Enter passphrase for key 'C:\Users\Administrator/.ssh/id_rsa':
    PTY allocation request failed on channel
    Welcome to GitLab, wyt!
    Connection to 47.111.84.191 closed.

Gitlab-CI Build Docker-compose自动发布

  1. 创建项目 beta2 
    【ASP.NET Core分布式项目实战】(六)Gitlab安装
  2. 添加项目初始化

    # Git global setup
    git config --global user.name "wyt"
    git config --global user.email "786744873@qq.com"# Create a new repository
    git clone git@47.111.84.191:wyt/beta2.git
    cd beta2
    touch README.md
    git add README.md
    git commit -m "add README"
    git push -u origin master# Existing folder
    # cd existing_folder
    git init
    git remote add origin git@47.111.84.191:wyt/beta2.git
    git add .
    git commit -m "Initial commit"
    git push -u origin master# Existing Git repository
    cd existing_repo
    git remote rename origin old-origin
    git remote add origin git@47.111.84.191:wyt/beta2.git
    git push -u origin --all
    git push -u origin --tags
  3. 然后我们就可以看到我们的项目文件了
    【ASP.NET Core分布式项目实战】(六)Gitlab安装
  4. 编辑.gitlab-ci.yml 执行任务
    我们只需要在根目录添加 .gitlab-ci.yml  输入两行命令即可。

    rtest:
    script:
    - cd User.API
    - docker-compose up -d --build --force-recreate
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,910
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,435
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,250
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,061
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,693
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,731