美文网首页
gitlab-runner部署和配置细节

gitlab-runner部署和配置细节

作者: Terry_Qian | 来源:发表于2021-04-14 14:33 被阅读0次

    1 部署gitlab-runner

    # 先创建空的config.toml,否则启动会报错
    touch /home/gitlab-runner/config.toml
    
    version: '3'
    services:
      gitlab-runner:
        image: gitlab/gitlab-runner:latest
        privileged: true
        container_name: gitlab-runner
        volumes:
          - /var/run/docker.sock:/var/run/docker.sock
          - /home/gitlab-runner/config.toml:/etc/gitlab-runner/config.toml
        restart: always
    

    2 注册runner的配置

    1. 复制gitlab仓库URL,最后面需要有/
    2. 复制gitlab仓库token
    3. 名称,eg:runner
    4. 标签,eg:runner
    5. 运行环境,eg:docker
    6. 基础镜像,eg:alpine:latest

    3 修改gitlab仓库http下载链接(若非映射80端口需更改)

    https://blog.csdn.net/kimqcn4/article/details/87089588
    docker exec -it gitlab /bin/bash
    vi /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
    gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    host: gitlab_http.test.com
    port: 8080
    https: false

    time_zone: "Asia/Shanghai"

    ssh_host: gitlab_ssh.test.com

    ssh_port: 2222
    gitlab-ctl restart

    gitlab重启后该配置会失效,需要重新进入容器修改配置

    4 设置公共runner的运行配置

    runner-config.png runner-tag.png

    5 添加runner缓存配置(maven缓存,docker in docker缓存)

    vim /home/gitlab-runner/config.toml
    
    concurrent = 1
    check_interval = 0
    
    [session_server]
      session_timeout = 1800
    
    [[runners]]
      name = "runner"
      url = "http://1.???.??:1080/"
      token = "JJtvxxxxxxxxxxxxjp"
      executor = "docker"
      [runners.custom_build_dir]
      [runners.cache]
        [runners.cache.s3]
        [runners.cache.gcs]
        [runners.cache.azure]
      [runners.docker]
        tls_verify = false
        image = "alpine:latest"
        privileged = false
        disable_entrypoint_overwrite = false
        oom_kill_disable = false
        disable_cache = false
        volumes = ["/cache","/.m2","/var/run/docker.sock:/var/run/docker.sock"]
        shm_size = 0
    

    相关文章

      网友评论

          本文标题:gitlab-runner部署和配置细节

          本文链接:https://www.haomeiwen.com/subject/ymuclltx.html