GitLab Docker Compose File
version: '3.8'
services:
gitlab:
image: 'gitlab/gitlab-ce:18.2.8-ce.0'
container_name: gitlab
restart: always
hostname: '43.156.171.231' # 👈 替换为你的实际域名或 IP
environment:
GITLAB_OMNIBUS_CONFIG: |
# 外部 URL(必须与 hostname 一致)
# external_url 'https://gitlab.example.com' # 👈 如果用 HTTPS
external_url 'http://43.156.171.231' # 👈 如果用 HTTP(不推荐)
# Let's Encrypt 自动 HTTPS(可选,需 80/443 端口开放)
# letsencrypt['enable'] = true # false 关闭 Let's Encrypt
# letsencrypt['contact_emails'] = ['admin@example.com'] # 👈 替换为你的邮箱
# letsencrypt['auto_renew'] = true
# 时区
gitlab_rails['time_zone'] = 'Asia/Shanghai'
# 邮件配置(可选,示例为 SMTP)
# gitlab_rails['smtp_enable'] = true
# gitlab_rails['smtp_address'] = "smtp.example.com"
# gitlab_rails['smtp_port'] = 587
# gitlab_rails['smtp_user_name'] = "user@example.com"
# gitlab_rails['smtp_password'] = "password"
# gitlab_rails['smtp_domain'] = "example.com"
# gitlab_rails['smtp_authentication'] = "login"
# gitlab_rails['smtp_enable_starttls_auto'] = true
# gitlab_rails['gitlab_email_from'] = 'gitlab@example.com'
# 性能调优(根据机器配置调整)
unicorn['worker_processes'] = 2
sidekiq['concurrency'] = 10
# 禁用 Prometheus 监控(节省资源,可选)
prometheus_monitoring['enable'] = false
ports:
- '8080:80' # HTTP(Let's Encrypt 验证需要)
- '8443:443' # HTTPS
- '2222:22' # SSH(避免与宿主机 22 冲突)
volumes:
- './config:/etc/gitlab' # 配置文件
- './logs:/var/log/gitlab' # 日志
- './data:/var/opt/gitlab' # 仓库、数据库、附件等核心数据
shm_size: '256m' # 避免 Git 操作内存不足
# 可选:资源限制(根据机器调整)
# deploy:
# resources:
# limits:
# memory: 4G
# cpus: '2.0'