Creating Gitea Instance and Maven Repository with Reposilite for my Self-Hosted Projects

If you couldn't tell by now, I really like self-hosting things. I decided I'd like to start self-hosting my programming projects as well, it just became a matter of when I had enough time set aside to do that. This has become even more relevant now that I am starting to create and update a bunch of minecraft mods in preparation for my singleplayer world, which means a bunch of new projects.

I decided an instance of Gitea, which is basically just self-hosted Github, would be a great place to put my projects. In addition, I am going to have a lot of artifacts from minecraft modding, so I could use a maven repository to dump those for people to download or for other mod developers who want to extend one of my mods. For a maven repository manager I settled on Reposilite, who's web interface looks a lot better than some others I've seen, is pretty simple to use and more importantly has docker support.

https://i.imgur.com/lcLZmtl.png

A screenshot of my Reposilite instance.

Gitea

Gitea, being a fairly complete package with a lot of features, uses a relational database to store a lot of its data. Fortunately, there are a few options, one of them being PostgreSQL. Fortunately, I already have a postgres db running in docker, so I created a "gitea" database and created the necessary permissions for gitea.

https://i.imgur.com/UsToKu0.png

gitea in the database browser

Then I spent about an hour fiddling around with the recommended way to deploy Gitea with docker-compose before finally giving up. I want to like docker-compose, but it has given me so many problems in the past too, especially concerning networking. Maybe I am just an incompetent user, but once I just started using the docker commands I was making much quicker progress.

I managed to get gitea running and created an SSH tunnel to the exposed container port so I could complete the setup on my browser.

https://i.imgur.com/Odfu4uj.png

Part of the gitea setup page

The final step was to expose the container to the interwebz via nginx. I pretty much have a config file that I copy-paste for each of my sites now, making changes where necessary.

upstream giteaLoadBalance {
        server localhost:port;
}

server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;

        server_name git.fracturedcode.net;

        location / {
                proxy_pass      http://giteaLoadBalance;

                <proxy settings>
								......
                ......
        }
        <ssl settings>
        ......
}

server {
        if ($host = git.fracturedcode.net) {
                return 301 https://$host$request_uri;
        }

        listen 80 ;
        listen [::]:80 ;
        server_name git.fracturedcode.net;
        return 404;
}

The way this works is pretty simple, there are two virtual servers who respond to git.fracturedcode.net. One is for https and the other for http. The http server only lives to redirect people to the https server, while the https server proxies the gitea container, and could be load balanced if needed.

This is what it looked like after I reloaded nginx.

https://i.imgur.com/Ize2oGz.png

Basically the default Gitea homepage.

There's a few things I should do to configure this, like change the homepage and restrict sign ups and so on, but that would make this article too long. I will go over those another time.

Maven

Reposilite wasn't that difficult to set up. This is part of the recommended/example config file, which I followed, for the most part.

https://i.imgur.com/RNqjqOk.png

You can find this in the reposilite wiki [https://reposilite.com/docs/configuration](https://reposilite.com/docs/configuration)

I did have an issue initially, which was that I could not connect to the server. With some sleuthing I discovered that when the "hostname" parameter is blank, it implies "localhost", instead of "0.0.0.0". The server wasn't binding to what I thought it was. Even though I resolved this problem fairly quickly, I was super confused, because I really thought I had taken care with the configuration in the server, docker and nginx, and none of them were giving me errors.

https://i.imgur.com/r5pC7kl.png

The page that had me really confused

I will also note that I had to adjust the client_max_body_size nginx rule slightly for this website, since I am uploading things to it.

The next things I did were to add one of my modding projects to the maven repository by publishing with the gradle task in intellij, and then mirror the source code repository from Github on Gitea, but I will save that for later this week.

https://i.imgur.com/A5CzmNZ.png

A preview of the upcoming post and fruits of today's labor.

That's right, I have decided to post twice per week. I hope this will motivate shorter posts, though I won't be afraid to write those when I think it is right for the topic.

See you soon

-Fractured