(Build notes for getea server.)
Master Copy: https://github.com/feurig/gitea-configuration/blob/main/README.md
Gitea is a github like environment written in go. It provides git in an accessable form and allows you to create issues and write wiki pages like redmine and trac while also serving those repositories.
It is less convoluted than gitlab but more configurable than GCOS which it is based on.
We are building on a ubuntu/focal/cloud (from lxc's images) container with preseeded admin accounts.
apt-get -y install curl postgresql apache2 git
apt-get install postfix
... add as a Satelite (null client) ...
We want to use a single git user so we add it (will deal with this later)
adduser --system --shell /bin/bash --group --disabled-password --home /home/git git
We are going to use the package provided by packaging.gitlab.io
curl -sL -o /etc/apt/trusted.gpg.d/morph027-gitea.asc https://packaging.gitlab.io/gitea/gpg.key
deb [trusted=yes arch=amd64] https://packaging.gitlab.io/gitea gitea main" | sudo tee /etc/apt/sources.list.d/morph027-gitea.list
update.sh
apt-get install gitea
su - postgres
postgres@shelly:~$ createuser -P git
... add passwd
postgres@shelly:~$ createdb gitea -O git
Once gitea is installed go to myservername:3000 and navigate to the login in the upper right corner. Fill in the database,username, and dbpassword. Replace localhost with your servers fqdn. Create admin user (remember password here)
The first thing we want to do here is to mirror our github repositories.
We want to automate mirroring all of our repositories hosted on github (and bitbucket at some point). To do this we create a personal-access-token from our github developer tools. (save the token somewhere as it will not be recoverable). Once we have that token we select New migration. Fill in the https://github.com/myuser/myrepo and paste the token into the form, select mirror and the magic begins.
The default mirror interval is 8 hours with a minimum of 10 minutes. To fix this we add the following to /etc/gitea/app.ini
nano /etc/gitea.app.ini
...
[cron.update_mirrors]
SCHEDULE = @every 2m
[mirror]
DEFAULT_INTERVAL = 1h
MIN_INTERVAL = 2m
...
service gitea restart
We were able to automate mirroring our github repos with the help of some python provided by jpmens.net we modified it to allow us to separate local mirrors by the same organizations used by github though this required us to manually add the local users and organizations. The script in progress is here.
https://github.com/feurig/gitea-configuration/blob/main/mirror-repos.py
Like github mirroring bitbucket repositories required the creation of an application password. Then add a new "Git" migration using the application password as your credentials.
Gitea runs as an unprivilaged user on port 3000. To present it as a normal web server required a proxy server (apache). Since we had created letsEncrypt certificates for the old git server we moved them. There are still permissions issues with giving gitea access to the certificates which were worked around by copying the files.
Getting apache to proxy the https required enabling 'proxy_http2' and 'proxy' module (not 'proxy_http')
a2enmod proxy proxy_http2
- Gitea configuration etc/gitea/app.ini
- Apache configuration etc/apache2/sites-avaliable/gitea.conf
- Make gitea less ugly (add Susdev brand look and feel)
- Fix permission issues with certificate issues to allow for autorenewal if possible.
- Consider normalizing git user and repo locations.
- https://gitlab.com/packaging/gitea
- https://bryangilbert.com/post/devops/how-to-setup-gitea-ubuntu/
- https://luxagraf.net/src/gitea-nginx-postgresql-ubuntu-1804
- https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token
- https://jpmens.net/2019/04/15/i-mirror-my-github-repositories-to-gitea/
- https://websiteforstudents.com/how-to-install-gitea-git-server-on-ubuntu-16-04-18-04-18-10-with-mariadb/
- https://docs.gitea.io/en-us/config-cheat-sheet/
- https://charlesreid1.github.io/setting-up-a-self-hosted-github-clone-with-gitea.html
- https://charlesreid1.com/wiki/Gitea#Using_Binary
- https://mindefrag.net/2018/07/how-to-install-and-configure-gitea-a-self-hosted-github-like-service/