Globe

Kratos
专注于用户阅读体验的响应式博客主题
  1. 首页
  2. 搭建教程
  3. 正文

Ubuntu Docker 安装gitlab 并且nginx反代

2023年10月10日 33点热度 0人点赞 0条评论

环境:Ubuntu 2.04 TLS

1.更新系统:

sodu apt update -y && aot upgrade -y

2.安装docker:

sudo apt install docker.io containerd docker-compose

3.开启启动docker:

systemctl start docker
systemctl enable docker
systemctl status docker

4.使用下面的 mkdir 命令创建一个新的 GitLab 数据目录“/srv/gitlab”

mkdir -p gitlab; cd gitlab/

mkdir -p /srv/gitlab/{config/ssl,logs,data}

5.在“gitlab”项目目录中,使用 vim 编辑器创建一个新的“.env”文件:

vim .env

定义环境变量“GITLAB_HOME”,其值为 GitLab 数据目录“/srv/gitlab”,如下所示。

GITLAB_HOME=/srv/gitlab
单击Esc,并输入下面命令保存退出:

!wq

docker-compose.yml 脚本将使用 Gitlab 卷的环境变量。
6.创建 docker-compose.yml 脚本
vim docker-compose.yml
下面是完整的配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
web:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  hostname: 'gitlab.hakase-labs.io'
 
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      # Add any other gitlab.rb configuration here, each on its own line
      external_url 'https://gitlab.hakase-labs.io'
      gitlab_rails['gitlab_shell_ssh_port'] = 2224
      nginx['redirect_http_to_https'] = true
      nginx['ssl_certificate'] = "/etc/gitlab/ssl/fullchain.pem"
      nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/privkey.pem"
      nginx['ssl_dhparam'] = "/etc/gitlab/ssl/dhparams.pem"  
 
  ports:
    - '80:80'
    - '443:443'
    - '2224:22'
 
  volumes:
    - '${GITLAB_HOME}/config:/etc/gitlab'
    - '${GITLAB_HOME}/logs:/var/log/gitlab'
    - '${GITLAB_HOME}/data:/var/opt/gitlab'
    - '${GITLAB_HOME}/config/ssl:/etc/gitlab/ssl'

因为我用的nginx反代,所以我的配置是:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
web:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  hostname: 'gitlab.hakase-labs.io'
 
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      # Add any other gitlab.rb configuration here, each on its own line
      external_url 'https://gitlab.hakase-labs.io'
      gitlab_rails['gitlab_shell_ssh_port'] = 2224
      nginx['redirect_http_to_https'] = true
     gitlab_rails['smtp_enable'] = false
      gitlab_rails['time_zone'] = 'Asia/Shanghai'  
 
  ports:
   - '8080:80'
   - '1443:443'
   - '1124:22'
 
  volumes:
    - '${GITLAB_HOME}/config:/etc/gitlab'
    - '${GITLAB_HOME}/logs:/var/log/gitlab'
    - '${GITLAB_HOME}/data:/var/opt/gitlab'
   #- '${GITLAB_HOME}/config/ssl:/etc/gitlab/ssl'

7.接下来,转到“~/gitlab”项目目录并使用下面的“docker-compose”命令构建 GitLab 容器:

Next, go to the "~/gitlab" project directory and build the GitLab container using the "docker-compose" command below.

1
2
cd ~/gitlab
docker-compose up -d

现在使用以下命令检查 Ubuntu 系统上正在运行的容器和“LISTEN”端口:
docker-compose ps

8.如果需要反代的话进行下一步,nginx添加:
location / {
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_pass http://127.0.0.1:1443/;
}

OK,重启你的nginx:
systemctl restart nginx

所有流程结束。

标签: 暂无
最后更新:2023年10月10日

free

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

COPYRIGHT © 2024 EverythingIThink. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang