Created by: ston1th 2019-05-29 18:14:03
Updated by: ston1th 2026-07-11 07:00:05
Visibility: Public

OpenBSD Forgejo (Gitea)

Make

Cross Compile on Linux (requires go compiler):

git clone https://codeberg.org/forgejo/forgejo ~/forgejo
cd ~/forgejo
git reset --hard
git fetch
git checkout v15.0.4

CGO_CFLAGS= GOOS=openbsd TAGS="bindata" make build

Copy the gitea binary to /usr/local/sbin/gitea on the server.

Install

Dependencies:

pkg_add git bash
cat <<'EOF'> /etc/rc.d/gitea
#!/bin/ksh

daemon="/usr/local/sbin/gitea"
daemon_user="git"

. /etc/rc.d/rc.subr

rc_bg=YES
rc_reload=NO

rc_cmd $1
EOF
chmod 555 /etc/rc.d/gitea
rcctl enable gitea
rcctl set gitea flags web --work-path=/mnt/git --custom-path=/mnt/git/custom --config=/mnt/git/custom/conf/app.ini

useradd -m -b /mnt git
chmod 750 /mnt/git

Database

Basic config at OpenBSD MariaDB

CREATE DATABASE gitea CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL ON gitea.* TO 'gitea'@'localhost' IDENTIFIED BY '<password>';
FLUSH PRIVILEGES;

Content Security Policy

Content-Security-Policy: "default-src 'self';style-src 'self' 'unsafe-inline';script-src 'self' 'unsafe-inline' 'unsafe-eval';object-src 'none';frame-ancestors 'none';img-src da
ta: 'self';font-src data: 'self';worker-src data: blob: 'self';manifest-src data:;"