Continuous Integration Series - gitlab Construction of Private git Warehouse in Chinese

Keywords: GitLab Docker git jenkins

Continuous Integration Series: Construction of Chinese Private git Warehouse gitlab



target

gitlab+jenkins+docker+harbor+k8s initial implementation of continuous integration

gitlab introduction

GitLab is a web-based Git warehouse management tool developed by GitLab Inc., which uses MIT licenses and has wiki and issue tracking capabilities. Git is used as a code management tool and a web service is built on this basis.

Environmental preparation

  • System: Centos 7.4
  • docker v17.03
  • ip:10.79.163.41
  • Domain name: git.domain.com

gitlab installation


Get mirror image

docker pull beginor/gitlab-ce

Function
GitLab configurations (etc), logs, and data are usually placed outside the container for future upgrades, so please prepare these three directories first.

mkdir -p /opt/gitlab/etc
mkdir -p /opt/gitlab/log
mkdir -p /opt/gitlab/data

Once these three directories are ready, you can start running the Docker image. My suggestion is to use unless-stopped as a restart strategy, because it can stop the container manually and facilitate maintenance.

The complete operation commands are as follows:

docker run \
    --detach \
    --publish 443:443 \
    --publish 80:80 \
    --name gitlab \
    --restart unless-stopped \
    --volume /opt/gitlab/etc:/etc/gitlab \
    --volume /opt/gitlab/log:/var/log/gitlab \
    --volume /opt/gitlab/data:/var/opt/gitlab \
    beginor/gitlab-ce

gitlab upgrade

Small version upgrade (e.g. from 8.8.2 to 8.8.3), refer to the official instructions, stop the original container, and then delete:

docker stop gitlab
docker rm gitlab

Then we re-mirror a new version.

docker pull beginor/gitlab-ce

It also runs with the original run command.

docker run \
    --detach \
    --publish 443:443 \
    --publish 80:80 \
    --name gitlab \
    --restart unless-stopped \
    --volume /opt/gitlab/etc:/etc/gitlab \
    --volume /opt/gitlab/log:/var/log/gitlab \
    --volume /opt/gitlab/data:/var/opt/gitlab \
    beginor/gitlab-ce

GitLab will be automatically upgraded when it first runs. To prevent this, it is recommended to backup the directory / opt/gitlab / first.

Large version upgrades (e.g. from 8.7.x to 8.8.x) may cause errors with the above operation. If there are errors, try to log in to the container and execute the following commands in turn:

gitlab-ctl reconfigure
gitlab-ctl restart

Configure Mail Notification and Access Domain Names

Common Mailbox Service Configuration
Take Tencent Enterprise Post as an Example

docker exec -it gitlab bash
cat >>/etc/gitlab/gitlab.rb<<EOF
#Configure smtp
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "username@domain.com"
gitlab_rails['smtp_password'] = "yourpassword"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = 'username@domain.com'
gitlab_rails['smtp_domain'] = "exmail.qq.com"
#Configure external access address
external_url 'http://git.domain.com'
EOF
gitlab-ctl reconfigure
exit

gitlab landing

Browser access http://git.domain.com
The initial user is root. The first login will let you set the root password.

Posted by Amit Rathi on Wed, 15 May 2019 15:05:02 -0700