
1 利用docker-compose安装
1version: '3.7'
2services:
3 web:
4 image: 'gitlab/gitlab-ee:latest'
5 #restart: always
6 hostname: 'gitlab.example.com'
7 environment:
8 GITLAB_OMNIBUS_CONFIG: |
9 external_url 'https://gitlab.example.com'
10 ports:
11 - '22:22'
12 - '80:80'
13 - '443:443'
14 volumes:
15 - '/data/docker-compose/gitlab/config:/etc/gitlab'
16 - '/data/docker-compose/gitlab/logs:/var/log/gitlab'
17 - '/data/docker-compose/gitlab/data:/var/opt/gitlab'ssf
2 创建 ruby docker 镜像
1docker run -it --rm ruby /bin/bash
3 生成许可证
1gem install gitlab-license
2
3cat > license.rb
注意修改下面的开始和结束时间
1require "openssl"
2require "gitlab/license"
3
4key_pair = OpenSSL::PKey::RSA.generate(2048)
5File.open("license_key", "w") { |f| f.write(key_pair.to_pem) }
6
7public_key = key_pair.public_key
8File.open("license_key.pub", "w") { |f| f.write(public_key.to_pem) }
9
10private_key = OpenSSL::PKey::RSA.new File.read("license_key")
11Gitlab::License.encryption_key = private_key
12
13license = Gitlab::License.new
14license.licensee = {
15 "Name" => "none",
16 "Company" => "none",
17 "Email" => "example@test.com",
18}
19license.starts_at = Date.new(2020, 1, 1) # 开始时间
20license.expires_at = Date.new(2050, 1, 1) # 结束时间
21license.notify_admins_at = Date.new(2049, 12, 1)
22license.notify_users_at = Date.new(2049, 12, 1)
23license.block_changes_at = Date.new(2050, 1, 1)
24license.restrictions = {
25 active_user_count: 10000,
26}
27
28puts "License:"
29puts license
30
31data = license.export
32puts "Exported license:"
33puts data
34File.open("GitLabBV.gitlab-license", "w") { |f| f.write(data) }
35
36public_key = OpenSSL::PKey::RSA.new File.read("license_key.pub")
37Gitlab::License.encryption_key = public_key
38
39data = File.read("GitLabBV.gitlab-license")
40$license = Gitlab::License.import(data)
41
42puts "Imported license:"
43puts $license
44
45unless $license
46 raise "The license is invalid."
47end
48
49if $license.restricted?(:active_user_count)
50 active_user_count = 10000
51 if active_user_count > $license.restrictions[:active_user_count]
52 raise "The active user count exceeds the allowed amount!"
53 end
54end
55
56if $license.notify_admins?
57 puts "The license is due to expire on #{$license.expires_at}."
58end
59
60if $license.notify_users?
61 puts "The license is due to expire on #{$license.expires_at}."
62end
63
64module Gitlab
65 class GitAccess
66 def check(cmd, changes = nil)
67 if $license.block_changes?
68 return build_status_object(false, "License expired")
69 end
70 end
71 end
72end
73
74puts "This instance of GitLab Enterprise Edition is licensed to:"
75$license.licensee.each do |key, value|
76 puts "#{key}: #{value}"
77end
78
79if $license.expired?
80 puts "The license expired on #{$license.expires_at}"
81elsif $license.will_expire?
82 puts "The license will expire on #{$license.expires_at}"
83else
84 puts "The license will never expire."
85end
86
87ruby license.rb
生成 GitLabBV.gitlab-license license_key license_key.pub 这三个文件。
4 使用许可证
- 用 license_key.pub 文件替换 /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub 中的内容
- GitLabBV.gitlab-license 即是许可证,填入 ${address}/admin/license 地址并重启。
5 搞定收工


关注公众号 获取更多精彩内容
