DEV Community

Cover image for Self-host your own GitHub alternative
Alex Hyett
Alex Hyett

Posted on Originally published at alexhyett.com on

Self-host your own GitHub alternative

GitHub used to be the place where developers would go to store their code and find new repositories. I have had a GitHub account for 11 years now, back then I had a lot less grey in my beard and the world was a lot simpler.

For many, GitHub is still the only place where people store their code, but that is slowly changing. Thanks to AI, everyone and their gran, can now build software by simply prompting it. This has resulted in a massive amount of code being produced, mainly because some people think lines of code is a meaningful metric again and naturally all this code is being uploaded to GitHub.

You might be thinking, “it can't be that bad, surely not everyone is addicted to the slop machine”.

However, in GitHub's August blog post going over their 7-hour outage, they say that the number of commits per month has gone from 1.4 billion in April to 2.9 billion in August.

image 22

It is definitely clear that GitHub is struggling under the load. However, that doesn't explain everything. It is only in the last year that people have really started vibe coding in earnest, but GitHub has been having problems since 2019.

Of course, it could just be a coincidence that Microsoft acquired GitHub at the end of 2018 and GitHub has been having issues ever since.

For me the last straw was last year when Microsoft moved GitHub to be part of its Core AI team. GitHub have always said that they are not going to use your private repositories to train their models, they will however use any code that it sees while you are using GitHub Copilot.

At this point, I don't trust any AI company when they say they aren't going to train their models on your data. If you give them your data then chances are they are going to use it.

So where does that leave us?

Luckily there are a few places where you can still put your code and not worry too much about downtime or AI training.

If you are working on an open source application, and you want it to be publicly accessible, and you want to allow people to contribute, your best bet is Codeberg.

Codeberg is meant for public open source projects, so if you are mainly planning on hosting private repositories, you will need to look elsewhere.

Which I will cover in a minute.

Codeberg also has a strict no-AI, no crypto policy, so if you are looking for somewhere to host your vibe coded meme-coin project then keep it on GitHub or better yet, just leave it on your computer.

Codeberg is actually a hosted version of ForgeJo which in itself is a fork of Gitea or git-ee-uh as I kept on pronouncing it.

I have been using ForgeJo for several years now to host code on my public server as well as on my home server, and it has been very reliable. For personal projects, ForgeJo does everything that I used to do with GitHub, and it even has an alternative to GitHub actions, so you can run all your builds without hitting any limits.

If you are prone to a bit of vibe coding, then you can store your code on your own server without any problems.

Quick Managed Hosting #

If the thought of having your own server seems like a lot of work, the easiest way to run ForgeJo is to set it up on Railway. This is what I did when first had a public Git server, and you can be up and running in a few clicks.

I should point out that this video is not sponsored by Railway I am just a customer, but I will include my affiliate link in the description if you want to get $20 free credit and help support this channel.

Railway - $20 free credit (affiliate link)

Railway make it really easy to deploy services in one click. There is already a template for ForgeJo which sets up things like Postgres and Redis for you ,and even includes a runner so you can run your builds.

Once you have your Railway account set up go to this ForgeJo Template and click Deploy Now. Here we set up a new project and pick where we want our storage account based.

You can also change any of the preconfigured properties or leave them with their defaults.

There is a few you might want to change, which is the admin's email address. It defaults to admin@example.com so you can change that to your own email address. You might also want to change the admin username which can be found further down.

The admin password is going to be automatically generated, and we can find out what that is once the application is deployed.

So let's deploy this and see what happens. In less than a minute everything should be deployed and ready to use.

To find out our admin password, we can then click on ForgeJo, Variables, and then we need to scroll down to FORGEJO_ADMIN_PASSWORD and then copy it.

Then go back to deployments and click on where your application is deployed. You can then sign in with the username and password you specified earlier and you are all set up.

From here I would set up a new password, and 2-factor authentication. Once that is done it is just a matter of either creating new repositories or migrating some away from GitHub.

Migrating repositories #

Migrating repositories away from GitHub is pretty simple. We can click on plus, then New Migration → GitHub.

If you want to import a private repository or include things like pull requests, issues, or releases then you will need to provide a GitHub access key.

To create a GitHub Access Key you need to go to GitHub then Settings, Developer Settings and Personal access tokens.

You can then either create a fine-grained access token or a classic token.

For fine-grained tokens you need to make sure read-only access to Contents and Metadata are given and that it can access all the repositories you want to migrate across.

For classic tokens you just need to make sure that repo is clicked so it has access to all your repositories.

I would keep the expiry short if you are doing a one time migration, or use a longer one if you are planning on setting up a mirror.

If you have your own domain name, then you can also set up Railway to use that instead of the autogenerated one. To do this click on forgejo in your Railway project, then Settings and scroll down to Networking. You can then click on “+ Custom Domain”, enter in your domain, and it will give you the DNS details you need to set up with your DNS provider.

So that's the easy way to set up ForgeJo, but it isn't the most private. You will likely have to deal with AI bots trying to scrap your public repositories and keep up with any updates to prevent you from getting hacked.

The other way is to host on a computer inside your network.

Self Hosting #

Now I absolutely love self-hosting things. I have migrated a lot of the paid services I used to use into open source equivalents on my home network.

If you would like to know more about that then let me know in the comments.

The main benefit of hosting things locally is that they aren't accessible to the public internet so you don't need to worry about anyone gaining access to your server. You can be a bit more relaxed when it comes to updates, and you are not going to get any surprising bills.

One of those benefits is also a downside. If you want to use the ForgeJo APIs to interact with your repositories, then you can only do so from within your home network. This hasn't really been a problem for me, because all the automations I have running, are also running on the same server. The other downside is you need a spare computer if you want to have your ForgeJo instance running all the time.

You don't need a powerful computer to host your own services, you can either use an old computer or get an affordable mini pc off of eBay. My always on home server is a Dell Wyze 5070, it's this black square you can see on my pegboard behind me.

I bought this off of eBay for less than £100 or $140. I did upgrade the RAM on it before prices went crazy but even the 8 GB of RAM that most of them come with is plenty.

For those of us in Europe that have to worry about the cost of electricity, this thing only uses 5W when idle, which is most of the time, so it only costs me around £10 a year in electricity. Which isn't too bad.

Similar to hosting on Railway I just use Docker to host all my services. I write a docker-compose file for each service and use a shared Caddy instance to provide a wildcard SSL certificate for everything on my home network. I have a domain just for my local hosted services and I point a wildcard domain to the local IP address of the server in my home.

I can't access my services from outside my network unless I use a VPN but I rarely do that anyway.

If your interested in setting up ForgeJo on your home network I have made all the code for my local ForgeJo setup available for my Senior tier Patreon subscribers.

Patreon #

Talking of Patreon. As you may have seen a few videos ago, I lost my YouTube monetisation when trying to move over to a business AdSense account. Thanks, Google!

So if you would like to support this channel and see more videos like this, then the best way is to subscribe to one of my Patreon tiers.

Subscribers to my Senior tier and above get early access to everything I create, as well code access, discounts on future courses, which I have one in the works at the moment, and your name featured at the end of my videos.

I would like to keep these videos free from corporate sponsorships if I can, but I need your support in order to do that.

Unlike most tech YouTubers on here, I haven't been caught up in the AI hype and will do a video soon on where I think the industry is headed when it comes to AI.

My plan for this channel is to focus on software engineering fundamentals, system design and self-hosting, so you can actually learn something that is going to be helpful whether you end up using AI or not.

Let me know in the comments what topics you would like to see.

I should also point out, that you can watch all my videos on PeerTube as well and I do release them slightly earlier on there compared to YouTube. If you have an account on the Fediverse then give me a follow.

Thanks for watching, and I will see you next time.

Top comments (0)