先创建gitlab目录 /opt/CICD/gitlab,然后准备ssl证书。
docker-compose.yml 文件内容如下:
version: '3'
services:
gitlab:
container_name: gitlab
image: gitlab/gitlab-ce:latest
restart: always
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://192.168.1.111:8082'
unicorn['worker_timeout'] = 60
unicorn['worker_processes'] = 2
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtpdm.aliyun.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "xxxxxx@aliyun.com"
gitlab_rails['smtp_password'] = "xxxxxxxxxxx"
gitlab_rails['smtp_domain'] = "smtpdm.aliyun.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'xxxxxx@aliyun.com'
gitlab_rails['gitlab_email_display_name'] = 'noreply@aliyun.com'
gitlab_rails['gitlab_shell_ssh_port'] = 8022
user['git_user_email'] = "xxxxxx@aliyun.com"
nginx['enable'] = true
nginx['listen_port'] = 80
nginx['client_max_body_size'] = '250m'
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.key"
nginx['ssl_ciphers'] = "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256"
nginx['ssl_prefer_server_ciphers'] = "on"
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
ports:
- "8082:80"
- "8443:443"
- "8022:8022"
volumes:
- "/opt/CICD/gitlab/config:/etc/gitlab"
- "/opt/CICD/gitlab/logs:/var/log/gitlab"
- "/opt/CICD/gitlab/data:/var/opt/gitlab"
gitlab-runner:
image: gitlab/gitlab-runner:alpine
networks:
shanhy-ci:
driver: bridge
external_url 建议使用域名,避免后续不必要的麻烦。
官方参考资料:https://docs.gitlab.com/ee/install/docker.html#install-gitlab-using-docker-compose
(END)