Docker practice: Docker installation Gitlab tutorial, worth collecting

1. Introduction to Gitlab

GitLab is an open source project for code warehouse management system. It uses Git as a code management tool and builds a web service platform on this basis.

Through this platform, a web system similar to Github can be implemented, which can realize functions such as browsing code, managing projects, managing team members, managing code branches, and code submission records. Gitlab is currently the most popular code version control platform among Internet companies.

2. Comparison between gitlab and github

gitlab: More suitable for internal project management within the company, used to manage project members, code submission, and project operation and maintenance. It is divided into community free version and enterprise paid version. For small and medium-sized companies, it is recommended to use the community free version, which has sufficient functions.

Github: As the "largest gay dating website", most of the projects in it are open source. Through the world's largest programmer exchange platform, you can share your technology and increase your visibility. It is not suitable for internal project management of the company.

3. Gitlab installation tutorial

GitLab officially recommends at least 4G of memory when installing [I ran with 8G], otherwise it may freeze or run very slowly . It is recommended that friends use a cloud service of 4G or above for testing, or build a virtual machine locally.

3.1 Search Gitlab mirror

docker search gitlab

3.2 Download the latest image of the free version of Gitlab community

Note: ce means community free version, ee means enterprise paid version

docker pull gitlab/gitlab-ce

3.3 Check whether the image is downloaded successfully

#Get the local mirror list to see if there is a gitlab-ce mirror

docker images

3.4 Run Gitlab image

docker run -d \
--hostname gitlab.xxx.com \
--name gitlab \
--restart always \
-p 8082:443 -p 8083:80 -p 8084:22 \
-v /etc/localtime:/etc/localtime:ro \
-v /usr/local/gitlab_data/gitlab/config:/etc/gitlab \
-v /usr/local/gitlab_data/gitlab/logs:/var/log/gitlab \
-v /usr/local/gitlab_data/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce

Parameter Description

  • -d specifies background running

  • --hostname specifies the host name

  • --name specifies the container name

  • -p port mapping 443 https port 80 http port 22 ssh port

  • --restart always Restart strategy after the container is stopped: always restart when the container exits

  • -v specifies that to mount the storage volume, first create the corresponding directory on the host host.

3.5 Configure the firewall to open the port of the cloud server

If you purchase a cloud server, you need to set the external network port to be open. The common Alibaba Cloud, Huawei Cloud, and Tencent Cloud can easily set up port opening, and you can Baidu by yourself.

The firewall setting command is as follows:

systemctl status firewalld #查看防火墙状态
systemctl start firewalld #开启防火墙
systemctl stop firewalld #关闭防火墙
firewall-cmd --list-ports #查看开放端口
#设置8082-8084端口开放
firewall-cmd --zone=public --add-port=8082-8084/tcp --permanent
firewall-cmd --list-ports #再次查看是否开放

3.6 Test whether it can be accessed normally

After the setting is completed, access through ip+port.

3.7 Configure https access

To configure SSL in nginx, you can refer to my previous article on the tutorial on installing nginx and configuring SSL on dockers.

3.8 Make sure the account name is root and the password is stored in the configuration file.

 After the initial installation of gitlab-ce, the password was placed in a temporary file. This file will be automatically deleted 24 hours after reconfigure is executed for the first time.

initial_root_password

Copy the Password content to the login interface

4. Gitlab takes up too much memory. Configuration optimization to reduce gitlab’s memory usage. 

To reduce the memory usage of gitLab, you need to modify its configuration file. After starting with the above configuration, the gitlab configuration file gitlab.rb is in the directory /opt/gitlab13.3/config. Then we can start editing this configuration file. Make the following changes:

1. Reduce database cache

postgresql['shared_buffers'] = "64MB"

2. Reduce the number of database concurrencies

postgresql['max_worker_processes'] = 1

3. Reduce the number of sidekiq concurrency

sidekiq['concurrency'] = 1

4. Reduce the number of processes

unicorn['worker_processes'] = 1
nginx['worker_processes'] = 2

5. Reduce timeout period

unicorn['worker_timeout'] = 10

6. Reduce database cache

postgresql['shared_buffers'] = "64MB"

7. Set the upper limit of worker memory smaller

unicorn['worker_memory_limit_min'] = "100 * 1 << 20"
unicorn['worker_memory_limit_max'] = "220 * 1 << 20"

8. Disable prometheus

prometheus_monitoring['enable'] = false

9. Turn off some monitoring and performance benchmark-related functions

prometheus['enable'] = false
prometheus_monitoring['enable'] = false
alertmanager['enable'] = false
node_exporter['enable'] = false
redis_exporter['enable'] = false
postgres_exporter['enable'] = false
pgbouncer_exporter['enable'] = false
gitlab_exporter['enable'] = false
grafana['enable'] = false
sidekiq['metrics_enabled'] = false

5. Port configuration

I directly use ip + port here. Modify the configuration as follows, so that the warehouse address has the port.

external_url 'http://43.136.xxx.xxx:8080'

Nginx in the container still defaults to 80 access

nginx['listen_port'] = 80

6. Summary

The above is the tutorial for installing gitlab with docker. If you encounter any problems during the installation process, please leave a message to communicate!

Guess you like

Origin blog.csdn.net/meimeieee/article/details/128474758