Build project management and code hosting platform gitlab in docker environment under Centos7 system

Posted by jammer on Sun, 16 Jan 2022 14:09:23 +0100

summary

GitLab is an open source project for warehouse management system. It uses Git as a code management tool and builds a Web service on this basis. Implement a self managed Git project repository, which can access public or private projects through the Web interface. Ability to browse source code, manage defects and comments. It can manage the team's access to the warehouse. It is very easy to browse the submitted versions and provides a file history library. It also provides a code fragment collection function, which can easily realize code reuse and facilitate searching when necessary in the future.

This setup is completed on the free server of Alibaba cloud.

Environmental description

Linux: 7.9.2009 minimum system installation

docker: 20.10.7

gitlab: 11.1.4-ce.0

Installation mode

The installation method is based on manual installation and typesetting file installation

Manual installation

1. Pull image

#docker pull twang2218/gitlab-ce-zh

2. Configure mirroring

Create a directory of gitlab configuration, logs and data

# mkdir -p /home/stone/gitlab/etc	# configuration file
# mkdir -p /home/stone/gitlab/log	# log file
# mkdir -p /home/stone/gitlab/data	# data file

3. Start container

docker run -d \
    --hostname www.201509.xyz \
    -p 8090:80 \
    -p 8443:443 \
    -p 8422:22 \
    --name gitlab \
    --privileged=true \
    --restart always \
    -v /home/stone/gitlab/etc:/etc/gitlab \
    -v /home/stone/gitlab/log:/var/log/gitlab \
    -v /home/stone/gitlab/data:/var/opt/gitlab \
    twang2218/gitlab-ce-zh:latest;

4. Adjust configuration

4.1,gitlab.rb

Modify / home / Stone / gitlab / etc / gitlab External in Rb file_ Change the URL information to the local IP address

vim /home/stone/gitlab/etc/gitlab.rb

Release external_url comment and modify the IP address

external_url 'http://103.xx.yy.zz'

IP address

4.2,gitlab.yml

Modify / home / gitlab / data / gitlab rails / etc / gitlab yml

vi /home/stone/gitlab/data/gitlab-rails/etc/gitlab.yml

Find the keyword ## Web server settings and change the value of host to the mapped external host ip address and port, which will be displayed in the gitlab clone address.

After modification, restart gitlab

#docker restart gitlab

Firewall open 8090 port mapping

#firewall-cmd --zone=public --add-port=8090/tcp --permanent
#firewall-cmd --reload

After restarting, the browser accesses

Enter in browser http://IP:port

Typesetting file installation

1. Preparation of typesetting documents

docker-compose.yml

version: '2'
services:
    gitlab:
      # Select Chinese version
      image: 'twang2218/gitlab-ce-zh:11.1.4'
      # Container name
      container_name: "gitlab"
      # Always restart the container automatically after the container collapses
      restart: unless-stopped
      # Permission switch
      privileged: true
      # Host name
      hostname: 'example.gitlab.com'
      # Environmental description
      environment:
        # time zone
        TZ: 'Asia/Shanghai'
        GITLAB_OMNIBUS_CONFIG: |
          external_url 'http://103.45.186.79'
          gitlab_rails['time_zone'] = 'Asia/Shanghai'
          gitlab_rails['smtp_enable'] = true
          gitlab_rails['smtp_address'] = "smtp.126.com"
          gitlab_rails['smtp_port'] = 465
          gitlab_rails['smtp_user_name'] = "xxxyyy@126.com"   # Add your own mailbox
          gitlab_rails['smtp_password'] = "*****" # password
          gitlab_rails['smtp_domain'] = "126.com"
          gitlab_rails['smtp_authentication'] = "login"
          gitlab_rails['smtp_enable_starttls_auto'] = true
          gitlab_rails['smtp_tls'] = true
          gitlab_rails['gitlab_email_from'] = 'aeropeak@126.com'
          gitlab_rails['gitlab_shell_ssh_port'] = 22
      # Port exposure
      ports:
        - '8080:80'
        - '8443:443'
        - '8422:22'
      # Mount volume
      volumes:
        - /home/stone/gitlab/etc:/etc/gitlab
        - /home/stone/gitlab/data:/var/opt/gitlab
        - /home/stone/gitlab/log:/var/log/gitlab

2. Run orchestration file

Go to docker compose Execute the following command in the directory where the YML file is located

#docker-compose up -d

verification

After restarting, the browser accesses

Enter in browser http://IP:port

The user name of the default account is root. On the first visit, it will be redirected to the password reset screen. After logging in, you can change the user name.


You can set an administrator password when logging in for the first time. The above is the construction process of gitlab in the docker environment based on CentOS 7 system.

Topics: Linux CentOS Docker GitLab