Gitlab series - gitlab environment construction

Installing Gitlab

  1. Setting environment variables
export GITLAB_HOME=/srv/gitlab
  1. Write docker-compose.yml
[root@origin ~]# mkdir -p /opt/docker-compose/gitlab
[root@origin ~]# vim /opt/docker-compose/gitlab/docker-compose.yml
version: '3.8'
    hostname: ''
    image: 'gitlab/gitlab-ce:14.2.4-ce.0'
    restart: always
        external_url ''
        gitlab_rails['gitlab_shell_ssh_port'] = 9022
        gitlab_rails['time_zone'] = 'Asia/Shanghai'
      - '9080:9080'
      - '9443:443'
      - '9022:22'
      - '$GITLAB_HOME/config:/etc/gitlab'
      - '$GITLAB_HOME/logs:/var/log/gitlab'
      - '$GITLAB_HOME/data:/var/opt/gitlab'
  1. Start Gitlab
[root@origin gitlab]# docker-compose up -d
  1. Start successful

    [note] the new version of Gitlab will not prompt to set the root password when logging in for the first time. The initial password is / etc/gitlab/initial_root_password, which is mapped to / SRV / Gitlab / config / initial on the host according to the mapping rules_ root_ password
[root@origin ~]# cat /srv/gitlab/config/initial_root_password 
# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#          If the password shown here doesn't work, you must reset the admin password following

Password: 1fBcwYj2Qbf5yyZubJJj51KH2T3BPvl02MoBAOiyiWc=

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
  1. Log in as root user

    Login succeeded. It is recommended to set the password first.
  2. HTTP export project

    The first time you visit the warehouse, you need to enter a password. You can choose to cache the password locally, otherwise you need a password for each operation
    Successfully exported
  3. SSH secret free export project
  • Generate key pair
$ ssh-keygen.exe -t rsa -C "kal" -f kal_id_rsa
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in kal_id_rsa.
Your public key has been saved in
The key fingerprint is:
SHA256:3f2nJxYnGOwDfjfqXptsVIO2aK6q1bchndVBUYEslk0 kal
The key's randomart image is:
+---[RSA 2048]----+
|            =E.+=|
|           + +.  |
|          ... .. |
|         ...o+..o|
|        S..o++oo.|
|        . ooB.*..|
|       . oo* =.=o|
|      .   o.+o++o|
|     ......+oo=o |
  • Warehouse configuration public key
  • Test ssh connection
$ ssh -T -p 9022
Welcome to GitLab, @root!
  • ssh export project

Configure mailbox

Gitlab configuration mailbox is a common configuration item. Here is a brief introduction. For other configuration items, please refer to the official documents
Take QQ email as an example
Most Gitlab configurations are in the / etc/gitlab/gitlab.rb file
Based on the previous mapping rules, this file can be found in the host

  • Modify configuration
  gitlab_rails['smtp_enable'] = true
  gitlab_rails['smtp_address'] = ""
  gitlab_rails['smtp_port'] = 465
  gitlab_rails['smtp_user_name'] = ""
  gitlab_rails['smtp_password'] = "Password or authorization code"
  gitlab_rails['smtp_authentication'] = "login"
  gitlab_rails['smtp_enable_starttls_auto'] = true
  gitlab_rails['smtp_tls'] = true
  gitlab_rails['gitlab_email_from'] = ''
  gitlab_rails['smtp_domain'] = ""
  • Reconfigure Gitlab
    It is recommended to execute gitlab CTL reconfigure in the container. If you restart the container, it will take a long time...
  • Set administrator mailbox

    After setting, the mailbox will receive an email to confirm the mailbox.

  • After confirmation, you can see that the mailbox has become verified
    Next, you can set the mailbox of the system
  • In order to test the email notification, we also need to register a user. Here, we can directly use the administrator to add an account, and the user can directly go to the mailbox for authentication
    Add user mailbox to notification list
  • Execute push operation

    Mail received successfully
  • Other common configurations
    Close Gravatar Avatar

    Close user registration

    The previous scattered knowledge points will be sorted out later

Keywords: Docker GitLab

Added by jmac2501 on Tue, 21 Sep 2021 09:58:05 +0300