some notes on installing Gitea

I’ve been running a heavily outdated version of Gitea. Rather than doing an update on it, I just reinstalled it.

This applies to installing Gitea version 1.24.3 on Void Linux with PostgreSQL as the backend.

installation procedure

I just list the commands with some short notes.
Stick to one shell session, or run and in any new shell session.

create group and user gitea

I’m using a group for services like gitea, grafana and whatever. If you want the user gitea to be in a group that does not exist yet, run i.e. .

export giteaVersion=1.24.3 <-- adapt that to your gitea version export giteaInstallDir=/opt/intra/srv/gitea-${giteaVersion} <-- adapt that to your install dir root@idoru:/$ useradd -g intra -d ${giteaInstallDir}/home -r -s /bin/bash gitea root@idoru:/$ passwd gitea

the parameters for are

  • create <home dir> as home dir.
  • create a system account.

database preparation

create role and database Gitea

create role gitea with login password 'your password here'; create database gitea with owner gitea template template0 encoding UTF8 LC_COLLATE 'en_US.UTF-8' LC_TYPE 'en_US.UTF-8';

Aside: typing SQL code in all upper case looks like 70’s code.

configure access for database user gitea in pg_hba.conf

Adapt the host line to the IP of the machine on which Gitea is running in PostgreSQL’s .

local gitea gitea scram-sha-256 host gitea gitea 192.0.2.10/32 scram-sha-256

test database access

With you should get a psql console with the database gitea as the current database to use.

set up the directories for Gitea

Gitea uses odd locations for the installation (see Installation from binary). I rather have Gitea installed in the standard directories, i.e., programs that are not installed and managed by the OS’ package manager, usually get installed in .

Gitea default Linux standard path
install dir
config files or
log files
mkdir -p ${giteaInstallDir}/{bin,conf,custom,data,home,repo} chmod -R 770 ${giteaInstallDir} chown -R gitea:devel ${giteaInstallDir} mkdir /var/log/gitea chown gitea:devel /var/log/gitea

I just made the dir to check what ends up in there, and move that to suitable location. The dir is for all the repositories managed by Gitea.

download Gitea binary, prepare Gitea binary execution

  • Download the Gitea binary from gitea download page into .
  • Download the corresponding GPG signature (file with suffix ).
  • Validate the signature of the binary.
  • Make the binary executable.
wget -O ${giteaInstallDir}/bin/gitea https://dl.gitea.com/gitea/${giteaVersion}/gitea-${giteaVersion}-linux-amd64 gpg --keyserver https://keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2 gpg --verify <signature>.asc <downloaded binary> chmod 550 ${giteaInstallDir}/bin/gitea export GITEA_WORK_DIR=${giteaInstallDir}

is the base dir of the installation. By default, gitea uses as the custom folder. You can set it explicitly with something like .

run Gitea binary

Run . Do not run the Gitea binary as root. but as a less privileged user, i.e. user gitea or some user in the group you used for the Gitea installation. Run gitea with

gitea web -c ${giteaInstallDir}/conf/gitea.conf --port 3000 --pid /var/run/gitea/gitea.pid

installer screens

If the binary is fired up for the first time with the installation dirs being empty, the web installer comes up. Open in your browser. localhost can be replaced with hostname.

When the installer comes up, it offers to set up an administrative user account. Create this administrative user account. For most settings in the installer, the defaults are sane. Some notable installer screen follow:

database setup

Initial Configuration

Initial Configuration
click on image to enlarge

x

Nothing special here. The proposed values are ok. 127.0.0.1* can be replaced with the hostname of the machine. If PostgreSQL runs on another machine you have to change the IP, or use the hostname or FQDN.

general settings

General Settings

General Settings
click on image to enlarge

x

Adapt the Site Title and check the rest of the settings.

optional settings

Optional Settings

Optional Settings
click on image to enlarge

x

The optional settings are the settings for the SMTP host where Gitea sends emails for notifications.

fix retarded file paths

The installation procedure dumps the dir into … WTF. In , section there is the line and in section , there is the line .

After stopping the Gitea server, change the data dir in both sections to :

[server] ... APP_DATA_PATH = /opt/intra/srv/gitea-1.24.3/data ... [database] ... PATH = /opt/intra/srv/gitea-1.24.3/bin/data/gitea.db ...

Move the files in to .

review gitea.conf

Here are the most relevant parts of my . I omit sections like , and here.

APP_NAME = base.lan Gitea server RUN_USER = gitea WORK_PATH = /opt/intra/srv/gitea-1.24.3/bin RUN_MODE = prod [database] DB_TYPE = postgres HOST = 127.0.0.1:5432 NAME = gitea USER = gitea PASSWD = ****************** SCHEMA = SSL_MODE = disable PATH = /opt/intra/srv/gitea-1.24.3/bin/data/gitea.db LOG_SQL = false [repository] ROOT = /opt/intra/srv/gitea-1.24.3/repo [server] SSH_DOMAIN = idoru DOMAIN = idoru HTTP_PORT = 3000 PROTOCOL = https ROOT_URL = https://idoru/gitea CERT_FILE = /opt/intra/srv/gitea-1.24.3/cert/gitea2.cert KEY_FILE = /opt/intra/srv/gitea-1.24.3/cert/gitea2.key APP_DATA_PATH = /opt/intra/srv/gitea-1.24.3/data DISABLE_SSH = false SSH_PORT = 22 LFS_START_SERVER = true LFS_JWT_SECRET = MVoz09IEK0ZOl-KFaF2vpZMjBrMf6bJiWaaXFlcgDFY OFFLINE_MODE = true [lfs] PATH = /opt/intra/srv/gitea-1.24.3/repo/lfs [log] MODE = file # valid log levels: Trace, Debug, Info, Warn, Error, Fatal. LEVEL = info ROOT_PATH = /var/log/gitea FILE_NAME = gitea.log [mailer] ENABLED = true SMTP_ADDR = ****************** SMTP_PORT = 465 FROM = gitea@base.lan USER = ****************** PASSWD =

run Gitea as a service

Void is using runit as the init system. I’ve the following shell script in :

unset GIT_CONFIG_GLOBAL mkdir -p /var/run/gitea chown gitea:devel /var/run/gitea su - gitea -c '/opt/intra/srv/gitea-1.24.3/bin/gitea web -c /opt/intra/srv/gitea-1.24.3/conf/gitea.conf --pid /var/run/gitea/gitea.pid' >/dev/null 2>&1 &

I fiddled with the runit coreservices scripts on my machine, so the startup deviates from default Void start-up. On Void, make sure to use the right number prefix for script, so that gitea is started when all dependencies like filesystems, network, etc are available.

we’re done

Start the Gitea server.

references

Gitea docs, Installation from binary

Gitea custom issue labels, Gitea GitHub, Advanced.yaml

x