In this Raspberry Pi Gitlab tutorial, I will be going through the steps to setting up a piece of software called GITLab, this 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. This can be quite useful as it provides a helpful visual interpretation of what is happening in your GIT repository.
It also offers the ability to easily manage things like pull requests and forks. 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.
Below is a list of the optional and recommended pieces of equipment for this Raspberry Pi Gitlab server tutorial.
Raspberry Pi 2 or 3
Installing the Raspberry Pi GITLab server
The process of installing the Gitlab software is pretty straight forward. I recommend only doing this on a fresh installation of Raspbian as the GITLab software can be quite resource intensive. We will be installing the community edition of Gitlab, 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 basically just 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 basically allows all your mail traffic to run through SMTP (Simple Mail Transfer Protocol). Whilst on the other hand Local only, does exactly what it says, and only routes mail traffic locally.
Select “OK” and press enter to continue.
3. On the next screen, we are going to just select “Local only”, this is because it is the easiest to setup.
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.
Once you have selected the option 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 [email protected] 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.
Select “OK” and press enter to finalize installation.
5. Once that is all done, we need to grab GITLab’s GPG (GNU Privacy Guard) key, 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 on, please note that this can take some time as there is 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, 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 following command:
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:
2. You will now be greeted by a screen asking you to set the password for the root account, 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.
3. Now you can login to GitLab with your new password, for the username make sure you use root. Once you are ready, press sign in.
4. Once we are logged into GitLab 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.
5. The New Project screen is filled with a variety of different options. GitLab allows you to import GIT projects from a vast variety 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”, this basically just means only our user can interact with the repository unless we specifically 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.
Once you are happy with what you have set here, press 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.
7. Now back in terminal, we will clone our brand new repository and add our first file. To get started we need to first set some details, you can change the user name and the email below to whatever you want.
git config --global user.name "Administrator" git config --global user.email "[email protected]"
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 will just be 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
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, 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 setup 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.