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.
1. Run GitLab Script
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
2. Install GitLab
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:
Once the installation completes give it a few minutes, as it will take some time for GitLab to get up and running.
3. Login to GitLab
Open up a browser from your computer and navigate to your Pi (
http://<HOSTNAME>.<DOMAIN>). This will bring up the login page for GitLab:
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:
Upon successful login, you will be directed to the Projects Dashboard. This screen is where your projects will be listed.
4. Configure Email Relay
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 chapter to learn how to configure your GitLab Instance.
You can follow my future articles on building Internet of Things devices and general chat regarding to life at Google at Baking Pi — An IoT Blog. :)