docker compose 搭建gitlab私服
# Gitlab 私服搭建
采用 docker compose 的方式去进行搭建
version: '3.9'
services:
gitlab:
# 这里固定一个版本防止迁移时候版本不兼容,当然也可以用最新
image: 'gitlab/gitlab-ce:16.0.6-ce.0'
restart: always
container_name: gitlab
hostname: 'gitlab'
environment:
# 配置 gitlab,对应的就是 gitlab.rb ,每个配置独占一行
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://git.bulkall.top'
nginx['enable'] = true
nginx['redirect_http_to_https'] = true
nginx['redirect_http_to_https_port'] = 80
# 这里的秘钥位置,需要自己将配置的秘钥放进去
nginx['ssl_certificate'] = "/etc/gitlab/ssl/git.bulkall.top.pem"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/git.bulkall.top.key"
# 开启 pages 功能
pages_external_url 'http://git-pages.bulkall.top'
gitlab_pages['inplace_chroot'] = true
gitlab_rails['lfs_enabled'] = true
# 设置时区为北京时间
gitlab_rails['time_zone'] = 'PRC'
# 邮箱通知
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'xx@foxmail.com'
gitlab_rails['gitlab_email_display_name'] = 'Super Code Farmer'
gitlab_rails['gitlab_email_reply_to'] = 'xx@foxmail.com'
# 邮件配置
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = 'smtp.qq.com'
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = 'xxx@foxmail.com'
gitlab_rails['smtp_password'] = 'xxxxx' # 这里是服务器的授权码
gitlab_rails['smtp_domain'] = 'foxmail.com' # SMTP协议的规范,smtp_domain应该是您的邮件服务器的域名
gitlab_rails['smtp_authentication'] = 'login' # 使用登录身份验证方法
# 和下面的 smtp_tls 配置不能同时为true,互斥
gitlab_rails['smtp_enable_starttls_auto'] = false
gitlab_rails['smtp_tls'] = true
puma['worker_processes'] = 2
puma['worker_timeout'] = 60
sidekiq['concurrency'] = 4
# 解决 GitLab 响应 Forbidden
gitlab_rails['rack_attack_git_basic_auth'] = {'enabled' => true, 'ip_whitelist' => ["0.0.0.0"], 'maxretry' => 300, 'findtime' => 5, 'bantime' => 60}
# 内存和CPU限制,worker_processes 配置声明使用2核CPU
ports:
- '10443:443'
- '1080:80'
- '1022:22'
volumes:
# 挂载宿主机目录可以根据实际情况挂载 . 挂在到当前路径下
- './gitlab-docker/config:/etc/gitlab'
- './gitlab-docker/logs:/var/log/gitlab'
- './gitlab-docker/data:/var/opt/gitlab'
- '/etc/localtime:/etc/localtime'
# 限制共享内存大小
shm_size: '2048m'
# 限制 docker 容器使用 cpu 核心数,以及内存
deploy:
resources:
limits:
cpus: '2'
memory: 2048M
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
ps: 如果配置文件执行报错,那么就将里里面的注释全部都删除掉。
上次更新: 2023/07/05, 13:10:43