gitlab docker安装

gitlab docker 安装

一、 安装

  • docker安装

    • 拉取镜像
      docker pull gitlab/gitlab-ce:rc

    • 使用docker-file创建容器

      ##docker file
      version: "3"
      services:
        gitlab:
          image: 'gitlab/gitlab-ce:rc'
          restart: always
          hostname: 'git.abc.com'
          environment:
            GITLAB_OMNIBUS_CONFIG: |
              external_url 'http://git.abc.com'
              gitlab_rails['gitlab_shell_ssh_port'] = 2228
          ports:
            - '127.0.0.1:8000:80'
            - '2228:22'
          volumes:
            - '/data/gitlab/config:/etc/gitlab'
            - '/data/gitlab/logs:/var/log/gitlab'
            - '/data/gitlab/data:/var/opt/gitlab'
            - '/etc/localtime:/etc/localtime:ro'
      
      ##项目启动命令##
      # docker-compose -f docker-gitlab-compose.yml  -p gitlab up  -d
      
      ##项目停止命令##
      # docker-compose -f docker-gitlab-compose.yml  -p gitlab down
      
  • 主机安装

    ####安装镜像源
    vim /etc/yum.repos.d/gitlab-ce.repo
    #添加内容如下,使用清华源,速度快
    [gitlab-ce]
    name=Gitlab CE Repository
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
    gpgcheck=0
    enabled=1
    
    #生成yum缓存
    yum makecache
    
    ####安装gitlab-ce
    yum install gitlab-ce
    

二、配置

  • gitlab配置修改

    vim /etc/gitlab/gitlab.rb
    
    #配置完成重启gitlab 重置配置
    gitlab-ctl reconfigure
    
    # 启动Gitlab所有组件
    gitlab-ctl start
    
    # 停止Gitlab所有组件
    gitlab-ctl stop
    
    # 重启Gitlab所有组件
    gitlab-ctl restart
    
    
  • nginx配置

    server
    {
    	listen 80;
    	server_name  git.abc.com;
    	return       301 https://git.abc.com$request_uri;
    	access_log off;
    }
    
    server
    {
            listen 443 backlog=5120;
    
            server_name git.abc.com;
            ssl on;
            ssl_certificate /usr/local/nginx/conf/cert/11.pem;
            ssl_certificate_key /usr/local/nginx/conf/cert/11.key;
            ssl_session_timeout 5m;
            ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
            ssl_prefer_server_ciphers on;
    		
    		set $node_port 8000;
    		
    		 location / {
                # 这个大小的设置非常重要,如果 git 版本库里面有大文件,设置的太小,文件push 会失败,根据情况调整
                client_max_body_size 50m; 
                proxy_redirect off;
                
    			#以下确保 gitlab中项目的 url 是域名而不是 http://git,不可缺少
                proxy_set_header Host $host; 
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    			proxy_set_header Upgrade $http_upgrade;
    			proxy_set_header Connection "upgrade";
    			proxy_pass http://127.0.0.1:$node_port$request_uri;
    		}
            location ~* /(seek|contribute|charm|pop|grade)
            {
    		if (!-e $request_filename) {
    			rewrite ^/(.*)  /index.php?s=/$1 last;
    		}
            }
    
            location ~* ^/uploads
            {
                    deny all;
            }
            location ~* ^/static
            {
                    deny all;
            }
    		if ($request_uri ~* \.(rar|7z|zip|sql|asp|jsp|php)) {
                    return 404;
            }
    
            if ($http_user_agent ~* (Apache)) {
                    return 403;
            }
    
    		location ~ .*.(svn|Git|cvs|asp|aspx|zip|rar) {
    			return 404;
            }
    		access_log logs/git_access.log;
            error_log  logs/git_error.log;
    }
    

三、docker安装更新

可以参考gitlab官方更新文档:https://docs.gitlab.com/omnibus/docker/

#1.拉取新的gitlab镜像
docker pull gitlab/gitlab-ce:latest

#2.修改docker-gitlab-compose.yml 中的gitlab image为最新镜像

#3.停止并删除gitlab的docker
docker-compose -f docker-gitlab-compose.yml  -p gitlab down

# 4.使用新镜像创建
docker-compose -f docker-gitlab-compose.yml  -p gitlab up  -d
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值