Today I want to show you how to install Gitlab correctly on a Raspberry Pi. Maybe you already tried to install Gitlab with another tutorial but it freezes during the process. I also had the issue with the other tutorials out there. That’s why I  decided to write my own one.

Step 1: Raspbian Stretch

Install Raspbian Stretch on your Pi. If you just want to use your Pi as a Server then you should only install the Lite Version without Desktop. If you use just the Lite version then don’t forget to configure your Raspberry PI with raspi-config before you continue.

I use on my Raspberry Pi 2 Raspbian Stretch Lite for GitLab and it runs perfectly.

Step 2: Configure Swap

You should definitly configure Swap! Otherwise Gitlab will freeze after installation. This is how you do it:
1. Open the swap config file:

sudo nano /etc/dphys-swapfile

2. Change following value:

CONF_SWAPSIZE=2048

3. Restart your Raspberry Pi

sudo shutdown -r now

Step 3: Install required dependencies:

Just run following command:

sudo apt-get install curl openssh-server ca-certificates postfix apt-transport-https

After that you need to add the GPG keys of GitLab to easily update your GitLab Server in the future:

curl https://packages.gitlab.com/gpg.key | sudo apt-key add -

Step 4: Install GitLab-CE

Now the party begins! Copy and paste following command:

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

and finally

sudo apt-get install gitlab-ce

This can take some minutes. Get a cup of coffee and wait…

Step 5: Configure GitLab

Once you have installed the GitLab package, you should change some settings in the config file of GitLab:
1. Open the GitLab Config

sudo nano /etc/gitlab/gitlab.rb

Note: If you use Raspbian Stretch Desktop then maybe you should use a visual editor because the file ist HUGE.

2.  Change the external_url (in my case line 13) to the url where gitlab will be available later.

external_url 'http://git.lab'

3.  Change the running workers to the minimum in order to reduce memory usage

Just uncomment and edit following lines:

unicorn['worker_processes'] = 2 ## line 689 for me 
sidekiq['concurrency'] = 9 ## line 745 for me 
prometheus_monitoring['enable'] = false ## line 1557 for me

PRO TIP: To jump to a specific line using nano just press Ctrl+_ (in my case (German Keyboard) Ctrl+# )

4. Start GitLab for the first time:

sudo gitlab-ctl reconfigure

This might take some time again… Drink another coffee! When you see “gitlab Reconfigured!” then you are ready to go.

Congratulations! Open the IP of your Pi in your Browser and see the results. If you see “Whoops, GitLab is taking too much time to respond. 502” then just wait  for a few minutes. That’s normal.

When you open GitLab for the first time then you will be asked to set a password for the user “root”. Set it and log in afterwards. Have Fun with Gitlab on your Pi!