Sign inSign up

1595225018/gitlab-ce

By 1595225018

•Updated about 8 years ago

Image
0

843

1595225018/gitlab-ce repository overview

⁠gitlab-ce文档

⁠1.Install GitLab using docker-compose

  • 1.Create a docker-compose.yml file
web:
  image: 'gitlab/gitlab-ce:latest'
  container_name: gitlab
  restart: always
  hostname: '10.0.0.117'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'http://10.0.0.117:9090'
      gitlab_rails['gitlab_shell_ssh_port'] = 2224
  ports:
    - '9090:9090'
    - '2224:22'
  volumes:
    - '/aling/docker/gitlab/config:/etc/gitlab'
    - '/aling/docker/gitlab/logs:/var/log/gitlab'
    - '/aling/docker/gitlab/data:/var/opt/gitlab'
  • 2.Make sure you are in the same directory as docker-compose.yml and run docker-compose up -d to start GitLab

⁠2.Update GitLab using Docker compose

Provided you installed GitLab using docker-compose, all you have to do is run docker-compose pull and docker-compose up -d to download a new release and upgrade your GitLab instance

⁠3.Configure GitLab

sudo docker exec -it gitlab /bin/bash
vi /etc/gitlab/gitlab.rb

You can also just edit /etc/gitlab/gitlab.rb

sudo docker exec -it gitlab vi /etc/gitlab/gitlab.rb
⁠4: GitLab集成LDAP登录并解决OpenLDAP的memberOf问题⁠

Setting up LDAP sign-in⁠

⁠step1:实现OpenLDAP的memberOf功能
  • 进入openldap容器
docker exec -it openldap /bin/bash
  • 在/etc/openldap目录下新建文件memberof_load_configure.ldif,内容如下:
dn: cn=module,cn=config
cn: module
objectClass: olcModuleList
objectclass: top
olcModuleLoad: memberof.la
olcModulePath: /usr/lib/ldap

dn: olcOverlay=memberof,olcDatabase={1}mdb,cn=config
objectclass: olcconfig
objectclass: olcMemberOf
objectclass: olcoverlayconfig
objectclass: top
olcoverlay: memberof
  • 在容器外执行命令,使文件生效sudo ldapadd -Q -Y EXTERNAL -H ldapi:/// -f memberof_load_configure.ldif。
⁠step2:在phpLDAPadmin中创建认证分组
  • 点击ou=grpups下的Create new entry here >>>> 右下角的 Default >>>>>ObjectClasses(groupOfNames) >>>>> RND 选cn (cn) 、 cn 填gitlab 、 members选分组成员(例如zegnlingyu)即可
⁠step3:用命令测试ldapsearch -x -LLL -H ldap:/// -b cn=zenglingyu,ou=users,dc=aling,dc=com dn memberof,如果输出如下表示成功
dn: cn=zenglingyu,ou=users,dc=aling,dc=com
memberOf: cn=gitlab,ou=groups,dc=aling,dc=com
⁠5:GitLab集成LDAP认证

1、修改GitLab配置文件/etc/gitlab/gitlab.rb

docker exec -it gitlab /bin/bash
vim /etc/gitlab/gitlab.rb

2、具体配置如下

 gitlab_rails['ldap_enabled'] = true

###! **remember to close this block with 'EOS' below**
 gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
   main:  # 'main' is the GitLab 'provider ID' of this LDAP server
     label: 'LDAP'
     host: '10.0.0.117'
     port: 389
     uid: 'uid'     # ldap中的User Name属性,可以设置为givenName等作为登录名字
     bind_dn: 'cn=admin,dc=aling,dc=com'
     password: 'daxue31105'
     encryption: 'plain'
     verify_certificates: false
     active_directory: true
     allow_username_or_email_login: false
     lowercase_usernames: false
     block_auto_created_users: false
     base: 'dc=aling,dc=com'
     user_filter: 'memberof=cn=gitlab,ou=groups,dc=aling,dc=com'  #和phpldapadmin上设置条目一样
#     ## EE only
#     group_base: 'ou=groups,dc=longma,dc=com'
#     admin_group: 'cn=gitlab,ou=groups,dc=longma,dc=com'
#     sync_ssh_keys: false

#
#   secondary: # 'secondary' is the GitLab 'provider ID' of second LDAP server
#     label: 'LDAP'
#     host: '_your_ldap_server'
#     port: 389
#     uid: 'sAMAccountName'
#     bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
#     password: '_the_password_of_the_bind_user'
#     encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
#     verify_certificates: true
#     active_directory: true
#     allow_username_or_email_login: false
#     block_auto_created_users: false
#     base: ''
#     user_filter: ''
#     ## EE only
#     group_base: ''
#     admin_group: ''
#     sync_ssh_keys: false 
EOS

Tag summary

Content type

Image

Digest

Size

-

Last updated

about 8 years ago

docker pull 1595225018/gitlab-ce