Skip to content

Installing GitLab on a Raspberry Pi 5

Published: at 08:06 PM

Introduction

The Raspberry Pi 5 is a versatile device that can handle various tasks, including hosting a self-managed GitLab server. GitLab is a powerful DevOps platform that offers Git repository management, CI/CD pipelines, and numerous collaborative tools. This guide will walk you through the process of installing and configuring GitLab on a Raspberry Pi 5.

Table of contents

Open Table of contents

Preparing Your Raspberry Pi

Before diving into the installation, it’s essential to ensure your Raspberry Pi 5 is ready. Start by making sure that your Raspberry Pi OS is up-to-date. Open your terminal and run the following commands to update the software:

sudo apt-get update
sudo apt-get upgrade -y

Updating your system ensures that all packages and dependencies are current, reducing the chances of encountering issues during the installation.

Installing Necessary Dependencies

GitLab relies on several key dependencies to function correctly. To install these, you’ll need to run:

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

These packages include tools for downloading GitLab, establishing secure SSH communications, and handling various libraries and certificates.

You will also need to add Gitlab GPG key to trusted APT certificates:

curl https://packages.gitlab.com/gpg.key | sudo tee /etc/apt/trusted.gpg.d/gitlab.asc

Setting Up Postfix for Email Notifications

While optional, configuring a mail transfer agent like Postfix is recommended if you want GitLab to send email notifications. Postfix allows GitLab to communicate with users via email, which is especially useful for notifications about project activity.

To install and configure Postfix, use:

sudo apt-get install -y postfix

During the installation, you’ll be prompted to select a configuration type. Choose “Internet Site” and enter your Raspberry Pi’s domain name (e.g., raspberrypi.local). This setup allows GitLab to send emails using the default system mailer.

Downloading and Installing GitLab

With your Raspberry Pi prepared and dependencies installed, it’s time to install GitLab. Start by adding the GitLab package repository to your system:

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

Next, install the GitLab Community Edition (CE) by running:

sudo apt-get install gitlab-ce

This process will download and install GitLab on your Raspberry Pi. Depending on your internet speed and the Pi’s processing power, this may take some time.

Configuring GitLab

After the installation, you need to configure GitLab to match your setup. Open the GitLab configuration file by running:

sudo vi /etc/gitlab/gitlab.rb

In this file, set the external URL to the address where you’ll access GitLab, for example:

external_url 'http://raspberrypi.local'

If you’re using an external storage device for GitLab data, adjust the data directories in this configuration file to point to your external storage location.

Starting GitLab

Once your configuration is set, initialize GitLab by running:

sudo gitlab-ctl reconfigure

This command will apply your configuration settings and start all necessary GitLab services.

If your are running this commands via SSH you may run into the Postgres error

execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8] (postgresql::enable line 59) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'

In this case edit sshd configuration file: /etc/ssh/sshd_config, and change LANG to this:

AcceptEnv LANG en_US.UTF-8

then restart sshd and reconnect:

sudo service sshd restart

Accessing GitLab

Now that GitLab is up and running, you can access it via your web browser. Enter the URL you configured (e.g., http://raspberrypi.local) in the browser’s address bar. On your first visit, use root password generated during installation, that can be found in /etc/gitlab/initial_root_password.

Monitoring GitLab Performance

Monitoring your GitLab instance can help maintain its performance. GitLab provides tools like gitlab-ctl status to check the status of services. For more advanced monitoring, you can integrate GitLab with tools like Prometheus, providing deeper insights into your server’s performance.

Conclusion

With GitLab installed on your Raspberry Pi 5, you now have a powerful, self-hosted platform for managing your software projects. Whether for personal use or collaborative development, GitLab offers a comprehensive suite of tools to streamline your workflow. For advanced configurations like SSL setup or CI/CD pipeline integration, refer to the official GitLab documentation.

References