Docker-compose one-click deployment of gitlab Chinese version method steps

Docker-compose one-click deployment of gitlab Chinese version method steps

1. Introduction to gitlab

Gitlab official address: https://about.gitlab.com/

GitLab is an open source version management system that uses Ruby on Rails to implement a self-hosted Git project repository that can access public or private projects through a web interface. It has similar functionality to Github, with the ability to browse source code, manage defects and comments. You can manage team access to the repository, it makes it easy to browse committed versions and provides a file history library. Team members can communicate using the built-in simple chat program (Wall). It also provides a code snippet collection function that allows easy code reuse and facilitates retrieval when needed in the future.

Gitlab is a code repository that can very well implement code management and team collaboration between developers. Currently, the most widely used application is to use Jenkins and GitLab to achieve continuous integration and deployment. The official recommended configuration is 2 core CPUs and 4G memory. This is because the overall operation of gitlab includes multiple processes, such as: nginx, postgresql, prometheus, redis, etc.

To this end, docker-compose is used here to deploy the gitlab Chinese community version on a single machine, so that everyone can better experience the powerful functions of gitlab. I won’t say much about the rest of the nonsense, just start working on it! !

2. Install Docker

1. Install docker dependency packages

[root@gitlab ~]# yum -y install yum-utils device-mapper-persistent-data lvm2

2. Add the Docker-ce image source and install it

1.1) Foreign sources (suitable for friends working abroad)

[root@gitlab ~]# yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo

1.2) Domestic Alibaba Cloud Source (suitable for friends working in China)

[root@gitlab ~]# yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

2) Download the server's package information to the local computer and cache it

[root@gitlab ~]# yum makecache fast

3) Install Docker CE

[root@gitlab ~]# yum -y install docker-ce

4) Configure the download docker image accelerator

Foreign accelerators:

[root@gitlab ~]# curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://bc437cce.m.daocloud.io

Domestic Alibaba Cloud Accelerator:

vim /etc/docker/daemon.json
#Enter the following and save:
{
"registry-mirrors": [https://9w1hl6qt.mirror.aliyuncs.com]
}

5) Reload systemctl and automatically start the docker

[root@gitlab ~]# systemctl daemon-reload
[root@gitlab ~]# systemctl start docker
[root@gitlab ~]# systemctl enable docker
[root@gitlab ~]# docker --version 
Docker version 18.09.0, build 4d60db4

3. Install Docker-compose

Download the Docker-compose binary and add execution permissions

[root@gitlab ~]# curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s-uname -m` -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed ​​Time Time Time Current
Dload Upload Total Spent Left Speed
100 617 0 617 0 0 590 0 --:--:-- 0:00:01 --:--:-- 590
100 11.2M 100 11.2M 0 0 498k 0 0:00:23 0:00:23 --:--:-- 737k
[root@gitlab ~]# chmod +x /usr/local/bin/docker-compose
[root@gitlab ~]# docker-compose --version
docker-compose version 1.23.2, build 1110ad01

4. Install Gitlab

1) Edit the yml file of docker-compose

[root@gitlab ~]# mkdir gitlab
[root@gitlab ~]# cd gitlab
[root@gitlab gitlab]# vim docker-compose.yml
 version: '2'
 services:
   gitlab:
    image: 'twang2218/gitlab-ce-zh:latest'
    container_name: "gitlab"
    restart: unless-stopped
    privileged: true
    hostname: 'gitlab'
    environment:
    TZ: 'Asia/Shanghai'
    GITLAB_OMNIBUS_CONFIG: |
     external_url 'http://ip or domain name reversed by nginx'
     gitlab_rails['time_zone'] = 'Asia/Shanghai'
     gitlab_rails['smtp_enable'] = true
     gitlab_rails['smtp_address'] = "smtp.163.com"
     gitlab_rails['smtp_port'] = 465
     gitlab_rails['smtp_user_name'] = "[email protected]"
     gitlab_rails['smtp_password'] = "Authorization code"
     gitlab_rails['smtp_domain'] = "163.com"
     gitlab_rails['smtp_authentication'] = "login"
     gitlab_rails['smtp_enable_starttls_auto'] = true
     gitlab_rails['smtp_tls'] = true
     gitlab_rails['gitlab_email_from'] = '[email protected]'
     gitlab_rails['gitlab_shell_ssh_port'] = 22
    ports:
     - '8181:80'
     - '8443:443'
     - '22:22'
    volumes:
     - /opt/gitlab/config:/etc/gitlab
     - /opt/gitlab/data:/var/opt/gitlab
     - /opt/gitlab/logs:/var/log/gitlab

Port mapping instructions and precautions:

  • The official gitlab image recommends that the container port 80 map to the host port 8181
  • The official gitlab image recommends that the container port 443 be mapped to the host port 8443
  • The official gitlab image recommends that the container port 22 map to the host port 22

⭐️The first two lines cannot be written at the same time. They should be left blank. You can go to the yml file detection website for detection:

https://www.bejson.com/validators/yaml_editor/

If your test is as shown in the figure below, it means that the yml file is completely correct:


Here is what I see on my Linux server:

2) Create relevant directories

[root@gitlab gitlab]# mkdir -p /opt/gitlab/{config,data,logs}
[root@gitlab gitlab]# ls -l /opt/gitlab/
total 0
drwxr-xr-x 2 root root 6 Dec 22 12:03 config
drwxr-xr-x 2 root root 6 Dec 22 12:03 data
drwxr-xr-x 2 root root 6 Dec 22 12:03 logs

The directory description is as follows:

  • config stores GitLab configuration information
  • data storage database
  • logs storage logs

3) Pull the Chinese version of gitlab image

[root@gitlab gitlab]# docker pull twang2218/gitlab-ce-zh:latest
latest: Pulling from twang2218/gitlab-ce-zh
8ee29e426c26: Pull complete
6e83b260b73b: Pull complete
e26b65fd1143: Pull complete
40dca07f8222: Pull complete
b420ae9e10b3: Pull complete
a218309dd589: Pull complete
5c60fd7ba0ce: Pull complete
659c2144b5a3: Pull complete
8289bbac0d0e: Pull complete
31bbd150e8a7: Pull complete
9114e78243fa: Pull complete
e242e5cd1314: Pull complete
0a079dc3f92c: Pull complete
f0e195b09fd2: Pull complete
6e23346e2f58: Pull complete
91f00659be69: Pull complete
a1031bcc5b2c: Pull complete
e3074327c7b1: Pull complete
a917618dbe42: Pull complete
Digest: sha256:62686b74c6fca5ece8ed582d03a126c5988423dd8a19ce70e9a22357ffcaf1c8
Status: Downloaded newer image for twang2218/gitlab-ce-zh:latest

[root@gitlab gitlab]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
twang2218/gitlab-ce-zh latest 18da462b5ff5 4 months ago 1.61GB

4) Start the gitlab container

Before starting, you need to modify port 22 of the host machine. Because the host machine occupies port 22, starting the container will fail because the mapping cannot be made. Modify it as follows:
vim /etc/ssh/sshd_config

By default, modify line 17: Port 2222

After modification, restart sshd: systemctl restart sshd

[root@gitlab gitlab]# netstat -tulnp | grep 22
tcp 0 0 0.0.0.0:2222 0.0.0.0: LISTEN 31889/sshd
tcp6 0 0 :::2222 ::: LISTEN 31889/sshd

Official launch:

[root@gitlab gitlab]# docker-compose up -d
Creating network "gitlab_default" with the default driver
Creating gitlab ... done

[root@gitlab gitlab]# docker-compose ps
Name Command State Ports
gitlab /assets/wrapper Up (healthy) 0.0.0.0:22->22/tcp, 0.0.0.0:8443->443/tcp, 0.0.0.0:8181->80/tcp

[root@gitlab gitlab]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
814e559dc728 twang2218/gitlab-ce-zh:latest "/assets/wrapper" 5 minutes ago Up 5 minutes (healthy) 0.0.0.0:22->22/tcp, 0.0.0.0:8181->80/tcp, 0.0.0.0:8443->443/tcp gitlab

5) Gitlab settings start up

[root@gitlab gitlab]# chmod +x /etc/rc.local
[root@gitlab gitlab]# ls -l /etc/rc.local
lrwxrwxrwx 1 root root 13 Dec 3 14:31 /etc/rc.local -> rc.d/rc.local
[root@gitlab gitlab]# echo "cd /root/gitlab && docker-compose up -d" >> /etc/rc.local
[root@gitlab gitlab]# tail -1 /etc/rc.local
cd /root/gitlab && docker-compose up -d

6)Gitlab management interface

Address: Enter the IP or domain name on line 12 of the yml file in the browser

User: root

Password: You need to manually set a password for the first login

As shown in the following figure:


The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Explain the deployment and configuration of Clickhouse Docker cluster with examples
  • Detailed explanation of docker-compose deployment php project example
  • How to deploy gitlab using Docker-compose
  • A brief analysis of the problem of mysql being inaccessible when deployed with docker-compose
  • Tutorial on how to quickly deploy clickhouse using docker-compose

<<:  Linux CentOS6.5 yum install mysql5.6

>>:  How to make vue long list load quickly

Recommend

Steps to configure nginx ssl to implement https access (suitable for novices)

Preface After deploying the server, I visited my ...

js to achieve simple calendar effect

This article shares the specific code of js to ac...

Example of how to build a Mysql cluster with docker

Docker basic instructions: Update Packages yum -y...

js realizes the magnifying glass function of shopping website

This article shares the specific code of js to re...

Oracle VM VirtualBox installation of CentOS7 operating system tutorial diagram

Table of contents Installation Steps Environment ...

How to fix the four sides of the table to scroll up, down, left and right

question: When I was doing project statistics rec...

Summary of MySQL character sets

Table of contents Character Set Comparison Rules ...

Tutorial on installing Elasticsearch 7.6.2 in Docker

Install Docker You have to install Docker, no fur...

This article will show you how to use Vue 3.0 responsive

Table of contents Use Cases Reactive API related ...

Mysql optimization Zabbix partition optimization

The biggest bottleneck of using zabbix is ​​the d...

JS, CSS and HTML to implement the registration page

A registration page template implemented with HTM...

In-depth understanding of the role of Vuex

Table of contents Overview How to share data betw...