GitHub has been recently (as of writing this article) acquired by Micro$oft. Some might like it, some might not. If you, as I do, belong to the GTFO camp, let’s face it: There is a quadrillion of possibilities, some are plain stupid, others perfectly perfect. I choose GiTea – and self-hosted on top of that!

The choice

Now this was a simple one. Why do I prefer Gitea over anything else? I do not have any, I mean ANY knowledge base of GitLab, Gitea, Gogs, or whatever else, I am a book yet to be written in this regard.

My choice was purely an intuitive one. I like tea. That’s it, full stop.

Now let’s get it installed and look at what it looks like. I definitely want to self-host it, as I do not want to move anymore. This will be my last Git GUI Repo of my life! 🙂

The install

Just find the latest bin / script, ironically enough, hosted on GitHub as the first iteration I found. Later, I managed to find one on gitea as well.

This install will be done on Linux, of course, as Linux is the go-to server platform OS today and Win just sucks. 

I’ve created a user named “git” some time ago and had a plain old git remote rpository on this server, so running gitea as the “git” user only makes sense to me.

su - git
wget https://dl.gitea.io/gitea/1.4.2/gitea-1.4.2-linux-amd64 -O gitea

This will get you everyhting you need. Almost. It will not get you the DB to use, but let’s talk about later on that.

Instructions say it clearly: 

./gitea web
2018/06/18 19:50:53 [W] Custom config '/home/git/custom/conf/app.ini' not found, ignore this if you're running first time
2018/06/18 19:50:53 [T] AppPath: /home/git/gitea
2018/06/18 19:50:53 [T] AppWorkPath: /home/git
2018/06/18 19:50:53 [T] Custom path: /home/git/custom
2018/06/18 19:50:53 [T] Log path: /home/git/log
2018/06/18 19:50:53 [I] Gitea v1.4.2 built with: bindata, sqlite
2018/06/18 19:50:53 [I] Log Mode: Console(Info)
2018/06/18 19:50:53 [I] XORM Log Mode: Console(Info)
2018/06/18 19:50:53 [I] Cache Service Enabled
2018/06/18 19:50:53 [I] Session Service Enabled
2018/06/18 19:50:53 [I] SQLite3 Supported
2018/06/18 19:50:53 [I] Run Mode: Development
2018/06/18 19:50:53 Serving [::]:3000 with pid 12321
2018/06/18 19:50:53 [I] Listen: http://0.0.0.0:3000

Now this should launch a web application that should guide you through the rest of the setup process – on the port 3000.

If you don’t have it open, open it now, at least for the time of installation

Opened browser, typed in http://bastart.spoton.cz:3000 and voila:

It was at this point, I realized, hell, I don’t have a database installed! On the other hand, it should be built with sqlite and it is even said at the startup. Well, select SQLite, change some settings to fit my needs and fire!

Tada, that was simple!

Now, how to get it started with systemd

This is quite simple, although there are some things we need to care about.

First of all, let’s create the service file in /etc/systemd/system/gitea.service with this content:

[Unit]
Description=Gitea. Git with a cup of tea
After=network-online.target
Before=multi-user.target
DefaultDependencies=no

[Service]
User=git
Group=git
LimitNOFILE=65536
WorkingDirectory=/home/git
ExecStart=/home/git/gitea web
KillMode=control-group
RestartSec=60
Restart=on-failure

[Install]
WantedBy=multi-user.target
Alias=gitea.service

I will not go through the systemd stuff in much detail, just make sure you are using absolute paths and the user running gitea is a non-priv user (i.e. not root)

Now there is one more thing to be aware of, namely the configuration file in /home/git/custom/conf/app.ini

By default, if using SQLite, the data path is not an absolute path, change it, so the PATH variable is set as ABSOLUTE PATH:

[database]
DB_TYPE = sqlite3
HOST = 127.0.0.1:5432
NAME = gitea
USER = gitea
PASSWD =
SSL_MODE = disable
PATH = /home/git/data/gitea.db

Now just do the other simple stuff:

systemctl enable gitea
service gitea start

To check if OK

service gitea status
gitea.service - Gitea. Git with a cup of tea
Loaded: loaded (/etc/systemd/system/gitea.service; enabled)
Active: active (running) since Tue 2018-06-19 11:38:15 UTC; 1min 11s ago
Main PID: 26651 (gitea)
CGroup: /system.slice/gitea.service
└─26651 /home/git/gitea web
Jun 19 11:38:15 debian-512mb-nyc3-01 systemd[1]: Started Gitea. Git with a cup of tea. Jun 19 11:38:15 debian-512mb-nyc3-01 gitea[26651]: 2018/06/19 11:38:15 [T] AppPath: /home/git/gitea Jun 19 11:38:15 debian-512mb-nyc3-01 gitea[26651]: 2018/06/19 11:38:15 [T] AppWorkPath: /home/git Jun 19 11:38:15 debian-512mb-nyc3-01 gitea[26651]: 2018/06/19 11:38:15 [T] Custom path: /home/git/custom Jun 19 11:38:15 debian-512mb-nyc3-01 gitea[26651]: 2018/06/19 11:38:15 [T] Log path: /home/git/log Jun 19 11:38:16 debian-512mb-nyc3-01 gitea[26651]: 2018/06/19 11:38:16 Serving [::]:3000 with pid 26651

journalctl -u gitea  
Jun 19 11:38:15 debian-512mb-nyc3-01 systemd[1]: Starting Gitea. Git with a cup of tea... 
Jun 19 11:38:15 debian-512mb-nyc3-01 systemd[1]: Started Gitea. Git with a cup of tea. 
Jun 19 11:38:15 debian-512mb-nyc3-01 gitea[26651]: 2018/06/19 11:38:15 [T] AppPath: /home/git/gitea Jun 19 11:38:15 debian-512mb-nyc3-01 gitea[26651]: 2018/06/19 11:38:15 [T] AppWorkPath: /home/git Jun 19 11:38:15 debian-512mb-nyc3-01 gitea[26651]: 2018/06/19 11:38:15 [T] Custom path: /home/git/custom 
Jun 19 11:38:15 debian-512mb-nyc3-01 gitea[26651]: 2018/06/19 11:38:15 [T] Log path: /home/git/log 
Jun 19 11:38:16 debian-512mb-nyc3-01 gitea[26651]: 2018/06/19 11:38:16 Serving [::]:3000 with pid 26651

 

The aftermath

I’ll poke around the new GUI and see what it brings…Â