Intro

Frustrated by the resource drain caused by GitLab on my Proxmox machine, I wanted to redo my CI/CD setup. The virtual machine running GitLab consistently used 4GB of RAM. This made me realize I needed a new setup, given I wasn’t fully utilizing GitLab’s feature set.

After some deep dives into alternatives, I settled on a Gitea and Jenkins combo. Gitea, a basic Git server, offered a lightweight repository hosting solution without big amount of RAM usage. Jenkins on the other hand is mainly to learn and see what it is capable of.

So, here’s to optimizing my CI/CD workflow.

Setting up the VM

I started of by building a new proxmox VM:

  • Almalinux 9
  • 2 CPU cores
  • 2 GB RAM

Once the VM was created using a template, the services could be installed. I will be using MariaDB as my database, but there are a couple databases that are supported.

Gitea

First install the needed packages:

sudo dnf install wget git mariadb

Next up is creating the user:

groupadd --system git
adduser system --shell /bin/bash --gid git --home-dir /home/git --create-home git

And the directories:

mkdir -p /var/lib/gitea/{custom,data,log}
chown -R git:git /var/lib/gitea/
chmod -R 750 /var/lib/gitea/
mkdir /etc/gitea
chown root:git /etc/gitea
chmod 770 /etc/gitea

After that I created a service file to make Gitea easily managable using systemd:

[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target

Wants=mariadb.service
After=mariadb.service

[Service]
RestartSec=2s
Type=notify
User=git
Group=git
WorkingDirectory=/var/lib/gitea/

ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
WatchdogSec=30s

[Install]
WantedBy=multi-user.target

The database also needs to be setup to store the repositories data:

mariadb -u root -h localhost
CREATE USER 'git'@'%' IDENTIFIED BY 'xxx';
CREATE DATABASE gitea;
GRANT all privileges ON *.* TO 'git'@'%' IDENTIFIED BY 'xxx';
exit;

And now make sure these 2 new services are enabled and running:

sudo systemctl start mariadb
sudo systemctl enable mariadb

sudo systemctl start gitea
sudo systemctl enable gitea

Jenkins

First install the needed repository and packages:

sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
sudo yum upgrade
sudo yum install fontconfig java-17-openjdk
sudo yum install jenkins

And now make sure Jenkins is enabled and running:

sudo systemctl enable jenkins
sudo systemctl start jenkins

For now I decided to only install the main server and not setup any worker nodes. I might set those up in the future but they would be redundant in my homelab.