
Introduction
Install Gitea for CI/CD using runners, requiring only 1GB memory.
Test Code: Code on GitHub
Requirements
An ubuntu 24.04 server with 1GB memory
Steps
Step 1 - Update Ubuntu
Since we have a new instance of Ubuntu, we need to do some updates:
apt-get update;
apt dist-upgrade -y;
apt-get install -y vim curl git sqlite3;
Step 2 - Install Gitea
Now let's download Gitea, set up a gitea user, create some working directories, set up a systemd service and start up gitea:
wget -O gitea https://dl.gitea.com/gitea/1.25.2/gitea-1.25.2-linux-amd64
chmod +x gitea
adduser \
--system \
--shell /bin/bash \
--gecos 'Git Version Control' \
--group \
--disabled-password \
--home /home/git \
git
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
cp gitea /usr/local/bin/gitea
cat > /etc/systemd/system/gitea.service <<'EOL'
[Unit]
Description=Gitea (Git with a cup of tea)
After=network.target
[Service]
RestartSec=2s
Type=simple
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
[Install]
WantedBy=multi-user.target
EOL
systemctl daemon-reload
systemctl enable gitea.service
systemctl start gitea.service
Now go to website at http://ip.address:3000, click through web interface to set up and login.
Then limit file permissions
chmod 750 /etc/gitea
chmod 640 /etc/gitea/app.ini
Step 3 - OPTIONAL - Install Runner
If you don't need runners/actions/CICD, you can skip this step.
You will need docker, so install it with this and create a act_runner user for it:
apt-get install -y docker.io; sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose adduser \ --system \ --shell /bin/bash \ --gecos 'act_runner' \ --group \ --disabled-password \ --home /home/act_runner \ act_runner sudo usermod -aG docker act_runner
Go to your web instance and grab the runner token from Profile - Settings - Runners
wget https://dl.gitea.com/act_runner/0.2.13/act_runner-0.2.13-linux-amd64
chmod +x act_runner-0.2.13-linux-amd64
./act_runner-0.2.13-linux-amd64 register --no-interactive --instance http://ip.address:3000 --token {your token}
You could run things immediately with ./act_runner-0.2.13-linux-amd64 daemon.
To use systemd instead, continue below...
Move everything to a more convenient place so that we can set everything up with systemd:
mv ./act_runner-0.2.13-linux-amd64 /usr/local/bin/act_runner chmod +x /usr/local/bin/act_runner mkdir -p /etc/act_runner mv .runner /etc/act_runner/ /usr/local/bin/act_runner generate-config > /etc/act_runner/config.yaml sed -i 's/file: .runner/file: \/etc\/act_runner\/.runner/g' /etc/act_runner/config.yaml mkdir -p /var/lib/act_runner chown -R act_runner:act_runner /var/lib/act_runner chown -R act_runner:act_runner /etc/act_runner cat > /etc/systemd/system/act_runner.service <<'EOL' [Unit] Description=Gitea Actions runner Documentation=https://gitea.com/gitea/act_runner After=network.target docker.service Requires=docker.service [Service] ExecStart=/usr/local/bin/act_runner daemon --config /etc/act_runner/config.yaml ExecReload=/bin/kill -s HUP $MAINPID WorkingDirectory=/var/lib/act_runner TimeoutSec=0 RestartSec=10 Restart=always User=act_runner [Install] WantedBy=multi-user.target EOL systemctl daemon-reload systemctl enable act_runner systemctl start act_runner
Try running the code from our github
Step 4 - SSH Key Authentication
If you do not want to use username and password, you can also use SSH keys.
On the machine with your project/code, create an SSH Key if you do not have one yet:
ssh-keygen -t ed_25519
Then copy the contents of ~/.ssh/id_ed25519.pub.
Go to Gitea in the Profile > Settings > SSH / GPG Keys > > Manage SSH Keys > Add Key and add your key.
Click on Verify Key. This will give you a command that you need to run on your machine against your ~/.ssh/id_ed25519.pub file to get a signature. Then copy the signature back into the Verify Key prompt.