Gitlab-01 - deploy enterprise private version warehouse service system

Refer to official documents: https://about.gitlab.com/install/

1, Installing and configuring dependent environments

Minimum 4G memory required

1 turn off firewall and SELinux

2. Install dependent packages

yum install -y curl policycoreutils-python openssh-server perl

2, Add GitLab package repository and install packages

1 add GitLab warehouse file

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash

FQDN of server configuration

external_url, the address that will be used to interact with the GitLab instance. Cloning via SSH / HTTP / HTTPS will use this address. Accessing the Web UI will reference this DNS entry.

Next, we declare a variable, which is used by general installation tools to deploy GitLab Server

EXTERNAL_URL="https://gitlab.sharkyun.com"

Note: gitlab sharkyun. Com needs an IP that can be normally resolved to GitLab Server

Install Git ce (Community Edition)

Git ee is the enterprise version, which is free of charge

yum install -y gitlab-ee

3, Configuring Gitlab Server

Gitlab configuration file / etc / gitlab / gitlab rb

1 configure time zone

gitlab_rails['time_zone'] = 'Asia/Shanghai'

2. Bind the monitored domain name or IP

external_url 'http://192.168.60.119'

This address is used to access the GitLab server.

3 use non default port 80

If you need to manually modify the port of nginx, you can use gitlab Set nginx ['listen_port'] = 8000 in Rb, and then gitlab CTL reconfigure again

Use gitlab CTL reconfigure to automatically configure and install the database. The initialization information is as follows (the configuration time is long for the first time):

[root@vm1 ~]# gitlab-ctl reconfigure   
.....

4. Configure email notification

If you want the email service provider of the Internet to send mail for your gitlab, you need to set it in the configuration file and open SMTP and POP3 functions at the email service provider.

For the difference between SMTP and POP3, visit https://www.zhihu.com/question/24605584

To be brief, SMTP is used for sending mail and POP3 is used for receiving mail.

Here, let me take mailbox 126 as an example to demonstrate

  1. First, we open SMTP at the mailbox service provider.

  1. Configure the email address and other information used by the system

In the configuration file: / etc / gitlab / gitlab The following modifications are made in RB

In this part, the following configuration is required whether using postmail or SMTP.

# Whether to open the system mailbox. It is enabled by default
gitlab_rails['gitlab_email_enabled'] = true

# Use this account to send mail, that is, the account that has opened the SMTP service
gitlab_rails['gitlab_email_from'] = 'my@126.cn'

# The name of the sender to be displayed in the sent message
gitlab_rails['gitlab_email_display_name'] = 'Git Lab Server Admin'

# The address of the system to receive mail. Generally, do not reply to the mail sent by the system
gitlab_rails['gitlab_email_reply_to'] = 'noreply@example.com'

# The title suffix of the message
gitlab_rails['gitlab_email_subject_suffix'] = '[gitlab]'

As for the mailbox suffix, the effect displayed after receiving the email is shown in the figure below

  1. After configuring the sending information of the system, set the account login authentication information of the mail service provider.

    If you want to use the mail service provider to send mail for the gitlab system, you need to log in, and the login needs to be verified first.

    So fill in the relevant information for login verification

    Note the value of gitlab above_ email_ The account of from must be consistent with the user name (smtp_user_name) here.

    gitlab_rails['smtp_enable'] = true
    
    # The configured password is not the login password of the mailbox, but the client authorization password of Netease mailbox, 
    # In the setting of Netease mailbox web page - POP3/SMTP/IMAP - client authorization password view.
    # See the figure below
    gitlab_rails['smtp_enable'] = true
    gitlab_rails['smtp_address'] = "smtp.126.com"
    gitlab_rails['smtp_port'] = 25
    
    # Use this account to send mail
    gitlab_rails['smtp_user_name'] = "my@126.com"
    gitlab_rails['smtp_password'] = "xxx"  # Authorization code, non login password
    gitlab_rails['smtp_domain'] = "126.com"
    gitlab_rails['smtp_authentication'] = "login"
    gitlab_rails['smtp_enable_starttls_auto'] = true
    gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
    
    # Sender account
    user['git_user_email'] = "username@domain.cn"
    # See more below
    # https://docs.gitlab.com/omnibus/settings/smtp.html
    
    # If you do not configure the sender, some mail servers will fail to send, 
    # Therefore, we'd better configure the account and sender and keep them consistent, so as to ensure compatibility
    

    SMTP client authorization code

  2. Start service

gitlab-ctl start

If the configuration file is reconfigured, the following steps need to be performed:

# Reload profile
[root@vm1 ~]# gitlab-ctl reconfigure

# Restart the service again
[root@vm1 ~]# gitlab-ctl restart
  1. Test email notification function

Use gitlab rails console command to test sending mail, as shown below:

irb(main):003:0> Notify.test_email('Recipient mailbox', 'Mail title', 'Message body').deliver_now

Example

[root@vm1 ~]# gitlab-rails console 
Loading production environment (Rails 4.2.10)
irb(main):001:0>  Notify.test_email('86000153@qq.com', 'Message Subject', 'Message Body').deliver_now
...
irb(main):002:0>quit
[root@vm1 ~]# 

3, Docker compose deployment

The simplest way

web:
  image: 'gitlab/gitlab-ee:latest'
  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'

Customize HTTP and SSH ports as follows:

web:
  image: 'gitlab/gitlab-ee:latest'
  restart: always
  hostname: 'gitlab.example.com'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'http://gitlab.example.com:8929'
      gitlab_rails['gitlab_shell_ssh_port'] = 2224
  ports:
    - '8929:8929'
    - '2224:22'
  volumes:
    - '$GITLAB_HOME/config:/etc/gitlab'
    - '$GITLAB_HOME/logs:/var/log/gitlab'
    - '$GITLAB_HOME/data:/var/opt/gitlab'

Added by thaynejo on Fri, 04 Mar 2022 00:59:20 +0200