使用docker安装gitlab
https://docs.gitlab.com/omnibus/docker/
https://docs.gitlab.com/omnibus/docker/#install-gitlab-using-docker-compose
https://docs.docker.com/engine/install/centos/
Gitlab-ce与Gitlab-ee的区别在于:
- gitlab-ce: 社区版
- gitlab-ee: 企业收费版
1. 下载gitlab-ce的docker镜像
下载当前最新版本, 最好指明版本号, 如下:
docker pull gitlab/gitlab-ce:13.9.1-ce.0
2. 采用docker compose安装gitlab-ce
配置环境变量GITLAB_HOME
:
vim ~/.bash_profile
追回内容:
export GITLAB_HOME=/Users/xx/gitlab
使环境变量生效:
source ~/.bash_profile
or
# 如果~/.zshrc里配置了source ~/.bash_profile
source ~/.zshrc
创建目录:
mkdir -p $GITLAB_HOME/config
mkdir -p $GITLAB_HOME/logs
mkdir -p $GITLAB_HOME/data
docker-compose.yml
文件内容:
version: '3'
services:
gitlab:
image: gitlab/gitlab-ce:13.9.1-ce.0
restart: always
hostname: gitlab.example.com
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.example.com'
# Add any other gitlab.rb configuration here, each on its own line
ports:
- '80:80'
- '443:443'
- '22:22'
volumes:
- '$GITLAB_HOME/config:/etc/gitlab'
- '$GITLAB_HOME/logs:/var/log/gitlab'
- '$GITLAB_HOME/data:/var/opt/gitlab'
本机测试示例:
version: '3'
services:
gitlab:
image: gitlab/gitlab-ce:13.9.1-ce.0
container_name: gitlab
restart: always
hostname: gitlab.zhuxiongxian.com
# hostname: gitlab.example.com
environment:
TZ: 'Asia/Shanghai'
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.zhuxiongxian.com'
# gitlab_rails['gitlab_shell_ssh_port'] = 10222
gitlab_rails['time_zone'] = 'Asia/Shanghai'
# gitlab_rails['time_zone'] = 'PRC'
# gitlab_rails['gitlab_email_enabled'] = true
# gitlab_rails['gitlab_email_from'] = 'gitlab-no-reply@example.com'
# gitlab_rails['gitlab_email_display_name'] = 'GitLab Administrator'
# gitlab_rails['gitlab_email_reply_to'] = 'admin@example.com'
gitlab_rails['backup_keep_time'] = 14515200
# gitlab_rails['smtp_enable'] = true
# gitlab_rails['smtp_address'] = "smtp.example.com"
# gitlab_rails['smtp_port'] = 587
# gitlab_rails['smtp_user_name'] = "no-reply@example.com"
# gitlab_rails['smtp_password'] = "changeMeToSomethingGood"
# gitlab_rails['smtp_domain'] = "example.com"
# gitlab_rails['smtp_authentication'] = "login"
# gitlab_rails['smtp_enable_starttls_auto'] = true
# gitlab_rails['smtp_tls'] = true
unicorn['worker_timeout'] = 60
unicorn['worker_processes'] = 2
sidekiq['concurrency'] = 4
logrotate['enable'] = true
# logging['logrotate_frequency'] = "weekly"
# logging['logrotate_rotate'] = 52
logging['logrotate_frequency'] = "daily"
logging['logrotate_rotate'] = 30
logging['logrotate_compress'] = "compress"
logging['logrotate_method'] = "copytruncate"
logging['logrotate_delaycompress'] = "delaycompress"
nginx['enable'] = true
nginx['listen_port'] = 443
nginx['redirect_http_to_https'] = true
# nginx['ssl_certificate'] = "/etc/ssl/certs/gitlab/server-cert.pem"
# nginx['ssl_certificate_key'] = "/etc/ssl/certs/gitlab/server-key.pem"
nginx['ssl_protocols'] = "TLSv1.1 TLSv1.2"
nginx['logrotate_frequency'] = "weekly"
nginx['logrotate_rotate'] = 52
nginx['logrotate_compress'] = "compress"
nginx['logrotate_method'] = "copytruncate"
nginx['logrotate_delaycompress'] = "delaycompress"
letsencrypt['enable'] = false
# Add any other gitlab.rb configuration here, each on its own line
# deploy:
# resources:
# limits:
# cpus: '0.1'
# memory: 1g
# reservations:
# cpus: '0.0001'
# memory: 20M
ports:
- '80:80'
- '443:443'
- '22:22'
volumes:
- '$GITLAB_HOME/config:/etc/gitlab'
- '$GITLAB_HOME/logs:/var/log/gitlab'
- '$GITLAB_HOME/data:/var/opt/gitlab'
3. 访问
访问external_url
配置的地址: https://gitlab.zhuxiongxian.com