Raspberry Pi GITLab Server

In this Raspberry Pi Gitlab tutorial, I will be going through the steps to set up a piece of software called GITLab.

Raspberry Pi Gitlab

This software is basically a more fully featured version of our GIT tutorial, but is also a lot more demanding on the Raspberry Pi.

If you have ever used a GIT hosting service like GitHub, then you will find GITLab a lot like that, with it providing a handy web frontend to GIT.

The web frontend can be quite useful as it allows for a helpful visual interpretation of what is happening in your GIT repository.

It also offers the ability to manage things like pull requests and forks easily. It can be very useful to set up if you plan to utilize GIT often, or with a team. It’s a bit of a step up from the basic Pi GIT server that I covered earlier.

Equipment List

Below is a list of the optional and recommended pieces of equipment for this Raspberry Pi Gitlab server tutorial.

Recommended

Optional

Installing the Raspberry Pi GITLab server

The process of installing the Gitlab software is pretty straightforward. I recommend only doing this on a fresh installation of Raspbian Jessie as the GITLab software can be quite resource intensive.

We will be installing the community edition of Gitlab, and you can check out their repository on it over at their community edition GIT page.

1. Before we install GITLab itself, we first need to install a few other things. The packages we need to install are CURL, the OpenSSH server, postfix and a package that allows “deb” to support the HTTPS protocol.

We can install these by using the following command:

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

Note: We will need to do a few extra things when installing postfix.

2. When Postfix begins to install you will be greeted with the following screen; this screen explains the various options that you can choose from.

The two easiest options to set up is the Internet Site option and the Local Only delivery option.

The Internet site option allows all your mail traffic to run through SMTP (Simple Mail Transfer Protocol). While, on the other hand, local only does exactly what it says, and only routes mail traffic locally.

Postfix

Select OK and press ENTER to continue.

3. On the next screen, we are going to select Local only, this is because it is the easiest to set up.

It is also useful as we only plan to use this GITLab installation within our local network, so we don’t want emails getting sent outside the local network anyway.

Postfix Config

Once you have selected the option that you want to utilize, select OK and press ENTER.

4. The next screen will be asking us to set the mail name for Postfix to utilize. You should set this to the fully qualified domain name you intend to use for email.

For example, if I wanted to utilize gus@example.com I would set the System mail name: to example.com

Since we don’t plan to utilize mail, we are just going to leave it as raspberrypi.

Postfix Local Only

Select OK and press ENTER to finalize installation.

5. Once that is all done, we need to grab GITLab GPG (GNU Privacy Guard) key, and this will allow the Raspberry Pi to encrypt and sign your data when communicating with their servers.

We can download and add the key with the following command:

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

6. With that finally done, we can start the next process. That is to begin the installation of all the packages that GITLab relies upon, please note that this can take some time as there are a fair few things that this script needs to do.

Run the following command to download and run the installation script.

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

7. Once that has finished installing we can proceed with finally actually installing Raspberry Pi GITLab server itself, this is another process that will take some time, and it is about a 150mb download.

Run this command in the terminal to begin the installation process.

sudo apt-get install gitlab-ce

8. The final command that needs to be run to finalize the installation of GITLab is the one shown below, this command configures and sets up all the settings for GITLab and installs all the required databases.

sudo gitlab-ctl reconfigure

Now GITLab should be successfully installed and ready to be used, I will go over creating your initial repository and making the first commit over the next couple of steps.

Creating your First GITLab Project

You should now have your Raspberry Pi Gitlab server up and running. It’s most likely you will want to set up your own project and repository, if you have never done this, then you should find the following information extremely handy.

1. To access our newly setup GitLab page we will need to go to the Raspberry Pi’s local IP Address if you don’t have the IP address you can quickly get it with the hostname command.

hostname -I

Once you have your Raspberry Pi’s IP address, load it up in your favorite web browser, in my case, I would type the following into my web browser.

http://192.168.1.105/

2. You will now be greeted by a screen asking you to set the password for the root account, and I recommend setting something secure for this, as this account has full control over the GitLab’s account.

Once you’re happy with your chosen password, press the Change your password button.

Gitlab first screen

3. Now you can log in to GitLab with your new password, for the username make sure you use root.

Once you are ready, press sign in and it will process to the next screen.

Gitlab Login Screen

4. Once we are logged into the Raspberry Pi GitLab server we will be greeted with the dashboard page, at the moment this contains nothing but a few buttons to create a new group or project.

For our tutorial we will be pressing the New Project button.

Gitlab Main Screen

5. The New Project screen is filled with a variety of different options. GitLab allows you to import GIT projects from a vast range of different services, such as GitHub and Bitbucket. However, for our tutorial, we will be just creating a new repository.

The main thing we need to set in here is the project name; this is the far-right text box for the project path. We will be using the name pimylifeup.

We will be leaving the visibility level set to Private, and this means only our user can interact with the repository unless we explicitly allow another one.

The two other options are Internal which allows any logged in user to be able to clone it, and Public which allows anyone to clone the repository.

Gitlab New Project

Once you are happy with what you have set here, click the “Create Project” button.

6. The screen you will be greeted with now is the empty project page, there is not a huge amount to do here at the moment, but we will soon be adding some files to this and populating it.

Gitlab Project Screen


7. Now back in the terminal, we will clone our brand new repository and add our first file.

To get started we need first to set some details, you can change the username and the email below to whatever you want.

git config --global user.name "Administrator"
git config --global user.email "admin@example.com"

8. With that done we can go about cloning our new repository if you chose to use a different project name make sure you swap out pimylifeup with your own name.

Now to clone the repository we will run the following couple of commands, this will grab the repository and move us into its directory.

cd ~
git clone http://raspberrypi/root/pimylifeup.git
cd pimylifeup

9. Now that we have cloned the repository, let’s create our first file and commit it. This command will create an empty file named Readme, but this should give you an idea on how to commit files.

To add and commit this file, run the following few commands, they should be somewhat self-explanatory.

touch README.md
git add README.md
git commit -m "add readme"
git push -u origin master

10. Now you can refresh your project page and now be able to see your new commit.

You can now click on the commit and check out the changes within the web interface rather than having to rely on Git’s command line

GITLab Commit Added

Congratulations, your GitLab server should now be up and running with its first project created.

We have only really scratched the surface of what GitLab is capable of doing, and you can also use it to set up CI Builds, manage forks and merge requests, and also utilize it to help lodge issues and set project milestones.

I hope that this tutorial has shown you how to set up a Raspberry Pi GITLab Server and that you haven’t run into any issues. It’s certainly a great Pi project for anyone who wishes to set up a solid GIT build.

If you have some feedback, tips or have come across any issues that you would like to share, then please don’t hesitate to leave a comment below.

4 Comments

  1. Avatar for Simon
    Simon on

    Update on my “poor performance” post…
    After hunting around a bit more, I stumbled across a throw away comment on another site.

    Quote: “Note that GitLab requires a 64-bit architecture and therefore the Raspberry Pi 3.”

    I’d forgotten the Pi 3 is 64-bit architecture (even though Jessie’s still 32-bit), so that might explain my problems.

    Food for thought.

    Cheers
    Simon

    1. Avatar for Jaime
      Jaime on

      Hello there! I have came across the same performance problem you comment on this article. Did you solve them?

    2. Avatar for BionicClick
      BionicClick on

      the fix is to use 64bit OS (non jesse) for now, like centos or ubuntu.

  2. Avatar for Simon
    Simon on

    Hi Gus, great tutorial (as always !) which inspired me to get around to doing this (been on the “to-do” list for FAR too long) and all went smoothly – but it’s definitely a fairly time consuming process in places.

    All installed OK, and got to the GUI (web) to create a test project, and it started going VERY slowly indeed. I kept getting error messages about the server taking too long to respond, ssh’ing into the Pi was painfully slow, very unresponsive, ‘free’ was showing almost the entire 1GB of RAM as used, so something is definitely wrong with my setup (this was a Pi 2, class 10 SanDisk microSD and USB keys for storage – identical setup to at least a dozen other Pi devices I have running, latest Jessie Lite, fresh/clean install, all patched up)

    I’ve dropped back to just using git and the command line (pretty much like the setup you did back in 2015) and this is all working fine (sharing between macos, Ubuntu 16.04 and Jessie Lite devices)
    Would be interested to hear what others have found trying this out. When I can get my hands on another Pi, I’ll try again and see if I come up with anything.

    Thanks for your always excellent posts, keep up the good work 😉

    Cheers
    Simon

Leave a Reply

Your email address will not be published. Required fields are marked *