Part 4 - Setting Up Git Server (GitLab)

This is the fourth post in the series of how to host your own git server on a Raspberry Pi

You have successfully set your Mail Server in the previous post. We will now look into installing git server on our Raspberry Pi. There are many self-hosted options when it comes to git — Gogs, Gitea, Phabricator — but none of them come close to the ease of use and the number of features offered by GitLab. Hence we will be using the latter for our self-hosted git server.

Image for post
Image for post

Start by running the GitLab setup script on your Pi. This will install the necessary dependencies and add package repositories for GitLab.

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash

Image for post
Image for post
Running GitLab Setup Script

Once the setup script finishes, you can proceed with installation:

sudo EXTERNAL_URL=”http://<GITLAB-DOMAIN>" apt install -y gitlab-ce

The installation will get an EXTERNAL_URL field, the (local) address we are planning to host our git server. As mentioned in part 2, we are planning to make this address: git.<HOSTNAME>.<DOMAIN>

Image for post
Image for post
Running GitLab Install

Once the installation completes give it a few minutes, as it will take some time for GitLab to get up and running.

Open up a browser from your computer and navigate to your Pi (http://192.168.X.X or http://<HOSTNAME>.<DOMAIN>). This will bring up the login page for GitLab:

Image for post
Image for post
GitLab Password Reset Screen

On your first visit, GitLab will ask you to reset the root password. Once reset, you will be re-directed to the login page, which you can login with the following information:

Username: root
Password: <PASSWORD>

Upon successful login, you will be directed to the Projects Dashboard. This screen is where your projects will be listed.

Image for post
Image for post
GitLab Projects Dashboard

In order for GitLab to use our Postfix setup from part 3 (for sending emails), we need to make a few configuration changes. Open Gitlab configuration file with the following:

sudo nano /etc/gitlab/gitlab.rb

Enter the following information at anywhere in the file:

## Email Configuration
gitlab_rails['gitlab_email_from'] = '<relay-email>'

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = 'localhost'
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_domain'] = 'localhost'
gitlab_rails['smtp_tls'] = false
gitlab_rails['smtp_openssl_verify_mode'] = 'none'
gitlab_rails['smtp_enable_starttls_auto'] = false
gitlab_rails['smtp_ssl'] = false
gitlab_rails['smtp_force_ssl'] = false

Save the configuration file and run reconfigure command from GitLab Control tool:

sudo gitlab-ctl reconfigure

That’s it! You have successfully installed GitLab on Ubuntu running on a Raspberry Pi. You can proceed to next post to learn how to configure your GitLab Instance.

Systems Engineer, specialized in building Internet of Things (IoT) devices and applications. Harvesting crops at Google. 💻

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store