tls证书生成
mkdir -p /data/gitlab/cert
cd /data/gitlab/cert
openssl genrsa -out fly.cn.key 2048
openssl req -new -x509 -key fly.cn.key -out fly.cn.crt -days 3650 -subj /CN=*.fly.cn
version: '3'
services:
gitlab:
container_name: "gitlab"
image: 'gitlab/gitlab-ce:13.10.2-ce.0'
restart: unless-stopped
hostname: 'gitlab.fly.cn'
environment:
TZ: 'Asia/Shanghai'
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.fly.cn:8443' #重要配置,gitlab访问地址
gitlab_rails['time_zone'] = 'Asia/Shanghai'
gitlab_rails['initial_root_password'] = "Gitlab123456" #重要配置,gitlab的root密码
gitlab_rails['gitlab_shell_ssh_port'] = 22222 #重要配置,ssh端口
#=============监控相关
prometheus['enable'] = true
grafana['enable'] = true
alertmanager['enable'] = true
node_exporter['enable'] = true
redis_exporter['enable'] = true
postgres_exporter['enable'] = true
gitlab_exporter['enable'] = true
#==========https配置
nginx['enable'] = true
nginx['client_max_body_size'] = '250m'
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/ssl/cert/fly.cn.crt" # 加密证书文件
nginx['ssl_certificate_key'] = "/etc/ssl/cert/fly.cn.key"
nginx['ssl_protocols'] = "TLSv1.1 TLSv1.2"
nginx['ssl_session_cache'] = "builtin:1000 shared:SSL:10m"
nginx['listen_addresses'] = ["0.0.0.0"]
nginx['http2_enabled'] = true
#========= 电子邮件的配置:
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "xxxx@xx.com"
gitlab_rails['smtp_password'] = "password"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = 'xxxx@xx.com'
#=======以下是与openldap集群配置
gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
main:
label: 'LDAP'
host: '192.168.11.192'
port: 389
uid: 'cn'
bind_dn: 'cn=admin,dc=fly,dc=cn'
password: 'Openldap123456'
encryption: 'plain'
verify_certificates: false
#ca_file: ''
#ssl_version: ''
active_directory: false
allow_username_or_email_login: false
#block_auto_created_users: false
base: 'ou=users,dc=fly,dc=cn'
user_filter: ''
attributes:
username: ['cn']
email: ['mail']
name: 'cn'
EOS
#-------------------------------------------
# 减少内存占用
unicorn['worker_memory_limit_min'] = "200 * 1 << 20"
unicorn['worker_memory_limit_max'] = "300 * 1 << 20"
# 减少 sidekiq 的并发数
sidekiq['concurrency'] = 16
# 减少 postgresql 数据库缓存
postgresql['shared_buffers'] = "256MB"
# 减少 postgresql 数据库并发数量
postgresql['max_connections'] = 8
# 减少进程数 worker=CPU核数+1
unicorn['worker_processes'] = 2
nginx['worker_processes'] = 2
puma['worker_processes'] = 2
# puma['per_worker_max_memory_mb'] = 850
# 保留3天备份的数据文件
gitlab_rails['backup_keep_time'] = 259200
ports:
- '8888:8888'
- '8443:8443'
- '22222:22'
volumes:
- /data/gitlab/config:/etc/gitlab
- /data/gitlab/data:/var/opt/gitlab
- /data/gitlab/logs:/var/log/gitlab
- /data/gitlab/cert:/etc/ssl/cert
- 配置Let’s Encrypt通知
admin area–>settings–>preferences–>pages–>Configure Let’s Encrypt