If you happen to have a RISC-V SBC (probably a VisionFive 2 or a newer board), you might want to install Gogs (and not Gitea or Forgejo, fuck ecosystem fragmentation) to host your private git repositories, the only problem is that there is no Gogs binary for RISC-V. So we need to compile it from source, fortunately it’s really easy, so I’ll keep the instructions as simple as possible and let the reader decide about the extra features.
Prerequisites
To build Gogs from source (and run) you will need go, a recent gcc version (for cgo-sqlite) and the git package installed. I’m also assuming that you’re running a fairly recent version of Debian for RISC-V, provided by the manufacturer of your SBC.
$ sudo apt install build-essential git
Go
First is first, you need to have go for RISC-V, so download and install it:
$ wget https://go.dev/dl/go1.22.2.linux-riscv64.tar.gz
$ rm -rf /usr/local/go && tar -C /usr/local -xzf go1.22.2.linux-riscv64.tar.gz
$ export PATH=$PATH:/usr/local/go/bin
You can check if go is installed correctly using go version
from the terminal, it should report the currently installed version of go. You might want to add the path to the go bin
directory to /etc/profile
.
$ go version
go version go1.22.2 linux/riscv64
Gogs
Start by adding a new user named git
:
$ sudo adduser --disabled-login --gecos 'Gogs' git
Execute all the following commands as the git
user:
$ sudo su git
Clone the Gogs repository to the gogs
subdirectory of your home (/home/git
), change into that directory and build gogs:
$ git clone --depth 1 https://github.com/gogs/gogs.git gogs
$ cd gogs
$ export CGO_ENABLED=1
$ export PATH=$PATH:/usr/local/go/bin
$ go build -tags "cert" -o gogs
Build takes about 3 minutes on a VisionFive 2 SBC. Now you can run Gogs and then install it normally by pointing your web browser to http://localhost:3000
:
$ ./gogs web
Others
If you want to setup nginx with a reverse proxy on a local domain, create a new file inside /etc/nginx/sites-available
called gogs
for example:
server {
listen 80;
server_name git.internal;
location / {
proxy_pass http://localhost:3000;
}
}
Replace git.internal
with the name of the internal host you want to setup Gogs onto, and remember to modify the URLs inside custom/conf/app.ini
. To setup HTTPS, create a self-signed certificate using gogs binary, move the cert.pem
and key.pem
files inside custom/https/
, configure nginx to proxy HTTPS and modify custom/conf/app.ini
to the new url and certificate path.
$ ./gogs cert -ca=true -duration=8760h0m0s -host=git.internal
$ mkdir custom/https && mv cert.pem key.pem custom/https/
Inside custom/conf/app.ini
:
[server]
PROTOCOL = https
EXTERNAL_URL = https://git.internal/
CERT_FILE = custom/https/cert.pem
KEY_FILE = custom/https/key.pem
To run Gogs at startup with Systemd (bleah), use the provided unit file scripts/systemd/gogs.service
(run those commands from a sudo-enabled user, not git
):
$ sudo cp scripts/systemd/gogs.service /etc/systemd/system/
$ sudo systemctl enable gogs
$ sudo systemctl start gogs
If the user you’re running Gogs under is not named git
, or the path to the gogs directory is not /home/git/gogs
, you will need to make some changes inside the service file before you enable the unit.