安装gitlab
shell
docker pull gitlab/gitlab-ce:latest
下载并安装 Docker Compose V2:
shell
sudo curl -L "https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
验证安装:
shell
docker-compose --version
新建gitlab文件夹
shell
mkdir gitlab
docker-compose.yml:
yml
version: '3.6'
services:
gitlab:
image: gitlab/gitlab-ce:latest
container_name: gitlab
restart: always
hostname: gitlab
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://IP地址:端口号'
gitlab_rails['gitlab_shell_ssh_port'] = 2222
ports:
- "端口号:端口号" #这边两个端口号要一致!!!很重要
- "4443:443"
- "2222:22"
volumes:
- ./config:/etc/gitlab
- ./logs:/var/log/gitlab
- ./data:/var/opt/gitlab
networks:
- gitlab-net
networks:
gitlab-net:
driver: bridge
在gitlab目录下启动gitlab
shell
docker-compose up -d
修改gitlab内部配置
进入gitlab容器
shell
vim /etc/gitlab/gitlab.rb
yml
external_url "http://IP地址:端口号/"
nginx['listen_port'] = 端口号
启动
shell
sudo gitlab-ctl reconfigure
配置域名
配置SSL证书
xxxxx.com域名
DNS解析
SSL证书解析
nginx
yml
server {
listen 443 ssl;
server_name xxxxx.com;
ssl_certificate xxxxx.com_bundle.crt;
ssl_certificate_key xxxxx.com.key;
location / {
proxy_pass http://localhost:端口号;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
最后等待gitlab容器完全启动,访问https://xxxxx.com就行了!
安装了四天,终于弄完了,特地写个笔记记录一下,防止下次再出问题。