Install and Configure Gitlab on Ubuntu

  Uncategorized

Introduction

Git is a release/version control system which has become an indispensable part of the programming process. It is a system that allows us to store and manage our projects remotely via the internet. This is safer than keeping project code on a local computer or external hard drive. Using version control allows you to save the current version of your project at any time. Later, if you want, you can return to any previous version of your project. The main component of version control systems is called a repository. The repository is a database which maintains a record of any changes in your files along with additional information related to those changes. For example, you can determine who made what changes, when they were made, and review comments and details about those changes. Git keeps all this information in a set of files inside a folder which is called .git.

Gitlab is Git store management system that can be managed via a web interface. It is independent software, not part of Git itself. It is a Ruby on Rails application for developers offering version tracking ability and can be run from a single server in a distributed (cluster) structure on running on multiple servers. It includes highly useful features such as a wiki, code-sharing, and error/issue tracking. It is a web application for controlling and managing your own projects.

In this tutorial, we will install GitLab, an open source self-hosted Git server. Through GitLab, you can do most administrative tasks, such as creating new repositories, managing access rights, and monitoring history. You can easily browse your files or code and quickly make small edits. GitLab is also adding support for collaboration tools.

  • Gitlab provides LDAP or LDAPS authentication.
  • You can create and manage users manually from a web interface.
  • Users can login to Gitlab with the OmniAuth authentication system. It supports Twitter, Google+, Github, etc.
  • Jenkins regular collection system can work with Redmine job tracking system by integrating.
  • Gitlab allows you to use the following regular external build system that can be integrated into the project (Atlassian Bamboo, Gitlab CI) and several types of project management software such as Assembla or Pivotaltrack.
  • There is an email-on-push feature from version 7.1.1. When this property is enabled-on-commit in the repository, it sends e-mail containing a diff.
  • It offers the ability to follow commits via e-mail.

Requirements

  • Familarity using the ProfitBricks Data Center Designer (DCD).
  • A provisioned server running Ubuntu. Make sure you check out the minimum requirements for installation. You can use a single core 2 GB server for an installation with less than 100 users. A server with 2 cores and > 2GB RAM is recommended.
  • Shell acces to the server using SSH or the DCD’s remote console.

Gitlab CPU Requirements

Here are general guidelines for allocating CPU resources.

  • 1 core supports up to 100 users
  • 2 cores supports up to 500 users
  • 4 cores supports up to 2,000 users
  • 8 cores supports up to 5,000 users
  • 16 cores supports up to 10,000 users
  • 32 cores supports up to 20,000 users
  • 64 cores supports up to 40,000 users

Gitlab RAM Requirements

Here are some guidelines for allocating RAM resources.

  • 2GB RAM + 2GB swap supports up to 100 users
  • 4GB RAM supports up to 100 users
  • 8GB RAM supports up to 1,000 users
  • 16GB RAM supports up to 2,000 users
  • 32GB RAM supports up to 4,000 users
  • 64GB RAM supports up to 8,000 users
  • 128GB RAM supports up to 16,000 users
  • 256GB RAM supports up to 32,000 users

Install Gitlab

We will use the recommended Omnibus Package Installer. It provides a .deb package for Debian systems. Additionally, the Omnibus installation takes care of housekeeping tasks such as restarting the worker process to manage memory use.

First, we will need to download the installer package. Download the latest installer package by visiting the GitLab download pageand choosing the Gitlab Community Edition version that you want to install.

If you want to install Gitlab 8.12.7 version on Ubuntu 16.04:

wget https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/xenial/gitlab-ce_8.12.7-ce.0_amd64.deb/download

If you want to install Gitlab 8.12.7 version on Ubuntu 14.04:

wget https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/trusty/gitlab-ce_8.12.7-ce.0_amd64.deb/download

The package is rather large ( >2GB )and may take a while to download. It will be named “download” if you use the wget commands above.

Once download completes, install GitLab using the dpkg command. dpkg can be used to install, uninstall, and build packages. One of the important points we need to remember is dpkg cannot download packages and its dependencies. But we can use the dpkgcommand directly because this Omnibus install package contains all the necessary packages and dependencies.

sudo dpkg -i download

You should see the following output similar to this:

Selecting previously unselected package gitlab-ce.
(Reading database ... 61632 files and directories currently installed.)
Preparing to unpack download ...
Unpacking gitlab-ce (8.12.1-ce.0) ...
Setting up gitlab-ce (8.12.1-ce.0) ...

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.
     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/

gitlab: Thank you for installing GitLab!
gitlab: To configure and start GitLab, RUN THE FOLLOWING COMMAND:

sudo gitlab-ctl reconfigure

gitlab: GitLab should be reachable at http://ubuntu
gitlab: Otherwise configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
gitlab: And running reconfigure again.
gitlab:
gitlab: For a comprehensive list of configuration options please see the Omnibus GitLab readme
gitlab: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
gitlab:
It looks like GitLab has not been configured yet; skipping the upgrade script.

After installation, use the following command to remove the download install package:

rm download

We have installed an open source community edition of GitLab using Omnibus installer. It is an integrated installer package that combines all dependencies and default settings. The installer combines Redis, Nginx, Sidekiq, Unicorn, and PostgreSQL. Unfortunately, the community edition with the Omnibus installer does not support switching to the MySQL database server. By default, omnibus-gitlab stores the Git repositories under the /var/opt/gitlab/git-data/repositories/ directory.

Configure Gitlab

The configuration file is located at /etc/gitlab/gitlab.rb. It is quite a lengthy file and contains numerous parameters, separated by each component. Some important settings to look at include external_url, where you can set your ip or your domain name. If you want to use external PostgreSQL setup, and email server settings, to set up your SMTP server, Redis, Nginx, LDAP, Kerberos, OmniAuth and etc settings, you can configuring them in this file. If you choose to modify any settings, you will need to reconfigure the installation using the sudo gitlab-ctl reconfigure command. You can get a list of enabled configuration options using the sudo gitlab-ctl show-config command.

Open the /etc/gitlab/gitlab.rb file using an editor, such as vi, to start modifying the configuration:

sudo vi /etc/gitlab/gitlab.rb

First, we need to edit external_url around line 11, find external_url and set the value to your IP or domain adress. (Pressing ikey for activate to edit with Vi editor)

external_url 'http://your_IP_adress_OR_your_Domain'

We need to add our email adress. We will use Gmail adress for this tutorial. Go to around line 22 and uncomment the lines and set your values to:

gitlab_rails['time_zone'] = 'UTC'
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = '[email protected]'
gitlab_rails['gitlab_email_display_name'] = 'your_display_name'
gitlab_rails['gitlab_email_reply_to'] = '[email protected]'

GitLab can be set up to allow users to comment on issues and merge requests by replying to notification emails. We must make sure have IMAP access enabled and allow less secure apps to access the account in Gmail settings. For reply by email settings, please go to ## Reply by email section around line 56 and uncomment the lines and set your values to:

## Reply by email
# Allow users to comment on issues and merge requests by replying to notification emails.
# For documentation on how to set this up, see http://doc.gitlab.com/ce/incoming_email/README.html
gitlab_rails['incoming_email_enabled'] = true
#
# # The email address including the `%{key}` placeholder that will be replaced to reference the item being replied to.
# # The placeholder can be omitted but if present, it must appear in the "user" part of the address (before the `@`).
gitlab_rails['incoming_email_address'] = "your_username+%{key}@gmail.com"
#
# # Email account username
# # With third party providers, this is usually the full email address.
# # With self-hosted email servers, this is usually the user part of the email address.
gitlab_rails['incoming_email_email'] = "[email protected]"
# # Email account password
gitlab_rails['incoming_email_password'] = "your_email_password"
#
# # IMAP server host
gitlab_rails['incoming_email_host'] = "imap.gmail.com"
# # IMAP server port
gitlab_rails['incoming_email_port'] = 993
# # Whether the IMAP server uses SSL
gitlab_rails['incoming_email_ssl'] = true
# # Whether the IMAP server uses StartTLS
gitlab_rails['incoming_email_start_tls'] = false
#
# # The mailbox where incoming mail will end up. Usually "inbox".
gitlab_rails['incoming_email_mailbox_name'] = "inbox"
#
gitlab_rails['incoming_email_log_directory'] = "/var/log/gitlab/mailroom"

The last settings we will modify in /etc/gitlab/gitlab.rb file are the SMTP settings. The SMTP settings are needed to have GitLab send notifications and sign-up confirmation emails to users. Go to the # GitLab email server settings # section, uncomment the lines and set your values to:

################################
# GitLab email server settings #
################################
# see https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/smtp.md#smtp-settings
# Use smtp instead of sendmail/postfix.

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.gmail.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "your_email_password"
gitlab_rails['smtp_domain'] = "smtp.gmail.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['smtp_openssl_verify_mode'] = 'peer' # Can be: 'none', 'peer', 'client_once', 'fail_if_no_peer_cert', see http://api.rubyonrails.org/classes/ActionMailer/Base.html

After making the change, save /etc/gitlab/gitlab.rb file and close the editor. (You can pressing ESC key to quit edit mode and fallback to command mode, write :wq! and ENTER key for save changes in /etc/gitlab/gitlab.rb file with the vi editor)

Now we need to apply our settings with sudo gitlab-ctl reconfigure command. It will configure and generate the various Gitlab services individual settings files. Generated files will be stored in the /var/opt/gitlab/gitlab-rails/etc/ directory. The main setting file will be /var/opt/gitlab/gitlab-rails/etc/gitlab.yml. Running the sudo gitlab-ctl reconfigure command (configuration management application) will create (for first time run) and subsequently update your settings and directories. It will restart GitLab components where needed, if we change anything in /etc/gitlab/gitlab.rb. When you run sudo gitlab-ctl reconfigure, it will overwrite the existing settings files.

sudo gitlab-ctl reconfigure

You should a significant amount of output with the end result similar to this:

Running handlers:
Running handlers complete
Chef Client finished, 237/324 resources updated in 01 minutes 47 seconds
gitlab Reconfigured!

Now our settings files have been created under the /var/opt/gitlab/gitlab-rails/etc/ directory. We have; database.ymlmail_room.ymlresque.ymlsmtp_settings.rbgitlab.ymlrack_attack.rbsecrets.ymlunicorn.rb files under the /var/opt/gitlab/gitlab-rails/etc/ directory.

We can check the status of Gitlab with this command:

sudo gitlab-ctl status

You should see the following output similar to this:

run: gitlab-workhorse: (pid 11120) 117s; run: log: (pid 10978) 170s
run: logrotate: (pid 11008) 161s; run: log: (pid 11007) 161s
run: mailroom: (pid 11091) 130s; run: log: (pid 10984) 169s
run: nginx: (pid 10995) 167s; run: log: (pid 10994) 167s
run: postgresql: (pid 10833) 209s; run: log: (pid 10832) 209s
run: redis: (pid 10746) 215s; run: log: (pid 10745) 215s
run: sidekiq: (pid 10969) 171s; run: log: (pid 10968) 171s
run: unicorn: (pid 10938) 172s; run: log: (pid 10937) 172s

And we can verify the reply by email settings are configured correctly:

sudo gitlab-rake gitlab:incoming_email:check

It should look as follows:

Checking Reply by email ...

IMAP server credentials are correct? ... yes
Init.d configured correctly? ... skipped (omnibus-gitlab has no init script)
MailRoom running? ... can't check because of previous errors

Checking Reply by email ... Finished

If necessary, you can make settings changes for Redis, Nginx, LDAP, and Kerberos in the /etc/gitlab/gitlab.rb file and then apply the changes by running the sudo gitlab-ctl reconfigure command. For more information: Omnibus Reference Settings.

Test Gitlab

Go to the IP adress or domain of the server where GitLab is installed using your browser. (The external_url setting in gitlab.rb.) On the first visit, you will be redirected to a password reset screen to provide a new password for the GitLab root account. You must create a new password with a minimum of 8 characters. Now you can login to Gitlab with root as the username and the new password. From here you can create projects and begin using GitLab.

Views: 11

LEAVE A COMMENT

What is the capital of Egypt? ( Cairo )