Part 1 CI: Setting up Gitlab on premise

·

2 min read

I setup Gitlab on my homelab as I would like to have a bit of control of my code.

The goal of this 2 part series is to

  1. Install Gitlab EE on premise

  2. Install Gitlab runner

What is needed is 2 VMs

  1. First VM is used as the Gitlab 192.168.1.110

  2. Second VM as the Gitlab Runner 192.168.1.111

To start let's install the prerequisites


sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates tzdata perl

Next install postfix, just accept the default


 sudo apt-get install -y postfix

Add Gitlab package repository and install

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash
sudo apt-get install gitlab-ee

After the installation go to another terminal, we will be creating a certificate

cd /etc/gitlab
sudo openssl req -newkey rsa:2048 -nodes -keyout server.key -x509 -days 3650 -out server.crt -subj "/CN=localhost" -addext "subjectAltName = DNS:localhost, DNS:192.168.1.110, DNS:gitlab.testlabs.local"
sudo chmod 400 server.*
sudo gedit /etc/gitlab/gitlab.rb &>/dev/null

#change the paramters in the gitlab.rb file
external_url 'https://gitlab.testlabs.local'
nginx['enable'] = true
nginx['client_max_body_size'] = '250m'
nginx['redirect_http_to_https'] = false
nginx['redirect_http_to_https_port'] = 80
nginx['ssl_certificate'] = "/etc/gitlab/server.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/server.key"

After that do

sudo gitlab-ctl reconfigure

Next go to your host /etc/host for my case, it is the machine ip

192.168.1.110 gitlab.testlabs.local

Next try to login using the url gitlab.testlabs.local, just accept the risk. Now go to the file. copy the password.

sudo nano /etc/gitlab/initial_root_password

The login username is root and password is as in the file.

Next login into gitlab server. You can either create your own username but you will require to use the administrator access (root) and approve the user.