Installing GitLab CE on a Raspberry Pi 4

I’ve been aiming to work on a bunch of smaller coding projects and with that, I wanted a way of storing them locally on my network. This meant I can manage all the git infrastructure and storing binaries with LFS and not having to pay monthly costs for GitHub or the like. This led me to set up my own instance of Gitlab Community Edition on my Raspberry Pi 4. There are a few documents out there on the topic which I have listed at the end for further reading but this article will discuss my setup in full.

1. Install and configure the necessary dependencies

For me I’m going to use GSuite to setup my SMTP web server for sending emails, we do that later in the config.

2. Setup HDD drive space.

For me, I’m using an external HDD atm. I just mounted one of the partitions to /var/opt/gitlab. I do this by editing my /etc/fstab file with the following line (you can ignore the comment, I’m keeping it here to explain the meaning of each value).

default means Use default options: rw, suid, dev, exec, auto, nouser, async
nofail means “do not report errors for this device if it does not exist.” Usually, our pi won’t boot if our external HDD is disconnected somehow.
dump 1 means the filesystem will be backed up by dump if used
fsck 2 means the system will be checked after root partitions 1

After you have finished editing you can mount your updated fstab file using mount -a

3. Download the deb file manually

Sadly, the package repository doesn’t seem to function for raspberry pi 4 (most likely because it’s still supplying stretch binaries instead of buster) however you are still able to download the image and install the application manually.

Go to https://packages.gitlab.com/gitlab/raspberry-pi2 and download the latest version (or the version you require). It does say raspberry-pi2 but it works fine for pi4.

For me, this was the following:

4. (Optional) Configure Swap memory

My raspberry pi 4 has 4gb of ram and GitLab recommends 8gb minimum. If you are using the 8gb model you can most likely skip this step.

There is a way to use disk space as memory called Swap. To do this, we edit the file /etc/dphys-swapfile. For me I mounted a 16gb partition (although I’m only using 4gb currently) to /var/swap/ and set the swap file to be /var/swap/swap https://nebl.io/neblio-university/enabling-increasing-raspberry-pi-swap/

  1. As root, edit the file /etc/dphys-swapfile and modify the variable CONF_SWAPSIZE to 1024:
    Using a command such as:
  2. Reboot

If you aren’t using an HDD (unlike me) you can also enable ZRAM swap which will increase performance when using an sd card https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/4105

5. (Optional) Setup your google SMTP Relay

If you are using GSuite like myself, you need to first set up your SMTP-Relay settings in your GSuite admin settings. I set it up like the following below:

Only addresses in my domains means that you can send using an account like gitlab@jflynn.xyz even though you don’t have a GSuite account with that email (saves paying for new email accounts that aren’t going to be used by people). If you use any of the other options for this make sure to change your gitlab_email_from to match.

Note: You will get an EOF error if these don’t match up correctly (say, you use an email at gitlab.example.com which is not apart of your domain.)

6. Configure GitLab

There are a few things to change in the file/etc/gitlab/gitlab.rb

    1. Change the external_url to your raspberry pi IP. You can use this one-liner to find it: ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'
      For me, I use an Asus Merlin router so wanted to set a nice hostname. You can do that on most routers by setting up a dnsmasq like this https://github.com/RMerl/asuswrt-merlin.ng/wiki/Custom-domains-with-dnsmasq so for mine I’m using http://gitlab.jflynn.xyz. You can also do this by editing your client hosts file for each pc/mobile you want to access GitLab from.
      Note: if you want to do HTTPS then you will need a CAA and setup Let’s Encrypt https://docs.gitlab.com/omnibus/settings/ssl.html#lets-encrypthttpsletsencryptorg-integration. Since I’m doing it on my LAN I’m not too bothered.
    2. As mentioned here https://docs.gitlab.com/omnibus/settings/rpi.html we want to reduce the number of running processes to make the system run a bit smoother:
    3. (Optional) Configure the SMTP settings in GitLab
      GSuite uses port 587 with TLS but they start unencrypted and are then upgraded via STARTTLS. This means we need to make sure that smtp_tls is set to false as this is only used on port 465 where connections start encrypted over TLS. You can read more at https://docs.gitlab.com/omnibus/settings/smtp.html#troubleshooting-ssltls

7. Run the reconfigure

gitlab-ctl reconfigure

Now you can head over to your ip address (the one set in external_url that we configured) and set up the root account.

That’s it!

If you have any questions feel free to post a comment or just drop me an email and I will get back to you.

Further Reading:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.