Home  >  Article  >  Development Tools  >  A brief analysis of how to use Dcoker to deploy GitLab on Linux

A brief analysis of how to use Dcoker to deploy GitLab on Linux

PHPz
PHPzOriginal
2023-04-03 11:52:57582browse
  1. Overview

GitLab is a warehouse management software based on the Git version control system with rich functions, including project management, code review, CI/CD and team management. This article will introduce how to use Dcoker to deploy GitLab on a Linux system and conduct simple configuration and testing.

  1. Install Docker

Before deploying Gitlab, we need to install Docker. Here we use Ubuntu 18.04 system and execute the following command to install docker:

sudo apt-get update 
sudo apt-get install docker.io

After installing Docker, check whether Docker is installed successfully:

docker --version

If you see Docker version information, Docker is installed successfully.

  1. Set the administrator password

Execute the following command to start the Gitlab container:

sudo docker run --detach --hostname gitlab.example.com \ 
    --publish 443:443 --publish 80:80 --publish 22:22 \
    --name gitlab \
    --restart always \
    --volume /srv/gitlab/config:/etc/gitlab \
    --volume /srv/gitlab/logs:/var/log/gitlab \
    --volume /srv/gitlab/data:/var/opt/gitlab \
    gitlab/gitlab-ce:latest

Among them, gitlab.example.com is Gitlab's domain name, /srv/gitlab/config, /srv/gitlab/logs, /srv/gitlab/data are Gitlab's configuration folder, respectively. Log folder, data folder.

After the container is running, we need to obtain the password of the default administrator and execute the following command:

sudo docker exec -it gitlab /bin/bash

After entering the container, execute the following command:

gitlab-rails console production
u=User.where(id:1).first
u.password='your_new_password_here'
u.password_confirmation='your_new_password_here'
u.save

This is done Reset the administrator password and exit the container.

  1. Configuring SMTP

Gitlab uses Sendmail by default to send emails. If you want to use SMTP to send emails, you need to change the configuration file. Here we use QQ mailbox as email. If you use other mailboxes, please change the SMTP address, port, username and password according to the actual situation.

First, create or edit gitlab.rb in the Gitlab configuration folder. You can use the following command to create the file and write the configuration:

sudo touch /srv/gitlab/config/gitlab.rb
sudo echo "gitlab_rails['smtp_enable'] = true" >> /srv/gitlab/config/gitlab.rb
sudo echo "gitlab_rails['smtp_address'] = \"smtp.qq.com\"" >> /srv/gitlab/config/gitlab.rb
sudo echo "gitlab_rails['smtp_port'] = 465" >> /srv/gitlab/config/gitlab.rb
sudo echo "gitlab_rails['smtp_user_name'] = 'your_qq_email_address'" >> /srv/gitlab/config/gitlab.rb
sudo echo "gitlab_rails['smtp_password'] = 'your_qq_email_password'" >> /srv/gitlab/config/gitlab.rb
sudo echo "gitlab_rails['smtp_domain'] = \"smtp.qq.com\"" >> /srv/gitlab/config/gitlab.rb
sudo echo "gitlab_rails['smtp_authentication'] = \"login\"" >> /srv/gitlab/config/gitlab.rb
sudo echo "gitlab_rails['smtp_enable_starttls_auto'] = true" >> /srv/gitlab/config/gitlab.rb
sudo echo "gitlab_rails['smtp_tls'] = true" >> /srv/gitlab/config/gitlab.rb

Pay attention to changing the QQ email and password in the configuration.

  1. Restart GitLab

After changing the configuration, you need to restart Gitlab for the configuration to take effect. Execute the following command:

sudo docker restart gitlab

After that, you can access Gitlab On the management page, enter the administrator account and new password to enter the system.

  1. Conclusion

This article only introduces the simple deployment and configuration of GitLab. For more detailed configuration parameters and information, please refer to the official GitLab documentation.

The above is the detailed content of A brief analysis of how to use Dcoker to deploy GitLab on Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn