DEV Community

Cover image for Self-Hosted Git Server with Gogs
Zorex Salvo
Zorex Salvo

Posted on

Self-Hosted Git Server with Gogs

What is Gogs?

Gogs (gogs.io) is a painless self-hosted Git service.

If you want to have your own GitHub-like service, it’s the best choice for me, since I made it work in less than an hour. Maybe you’re thinking, why would anyone want to create another service like GitHub when clearly there is already GitHub? Me, I needed to have private repositories for some of my projects. I can’t do that in Github unless I upgrade my account to a “Developer” plan for $7/month. To be honest, for me that is already expensive, to pay $7 just for private repositories, or maybe I’m just really poor. I’m not descrediting GitHub in any way, for public repos I’ll still choose GitHub.

First Things First

You’ll need: to have atleast basic knowledge on docker, and you need docker installed on your machine of course. PS, GOGS installation don’t have to be always dockerized, there are also bare metal installation guides but just for this post and the resources that I have we’ll stick to the docker version, also you’ll need a VPS for it to be accessible in the cloud.

When you’re done with the first steps, just pull the official gogs docker image:
$ docker pull gogs/gogs

You’ll also have to create a db (mysql, postgres, etc) container so:
$ docker pull postgres

Once db is ready, you can already run your gogs-container:

$ docker run --name gogs -d -v /var/gogs/:/data gogs/gogs

After that, once you open the address, you’ll see the Web UI Server Configuration where you’ll key-in all the server details, database, application name, administrator, host, domain, etc. Once you finished all of that, you’re now good to go.

For you reference:

  • I’m hosting it (together w this personal site and other personal apps) on a vps (1GB RAM, 1CPU Core, 20GB SSD Storage, 1TB Transfer, 40Gbps Network In 1000Mbps Network Out) for $5/mo; I bought my domain from Godaddy for less 1$; am using nginx for reverse proxy.

For personal git server, Gogs is really my to-go server. I haven’t had any problems setting it up, it has the essential functionalities you are looking for a git server, and it is really lightweight!

Top comments (3)

Collapse
 
remejuan profile image
Reme Le Hane

Seems like an interesting approach, but Gitlab will also give you unlimited free and 1000x10gb private repos, bitbucket gives unlimited private repos but limits you on team members.

This is only really a great solution if you a little more paranoid or an enterprise wanting to control the source code in your own data center.

Collapse
 
pinguxx profile image
Ivan

check gitlab, you can have private projects too

Collapse
 
rgo profile image
Ruben

Hi Zorex, great post! For me Gogs didn't really work out. I feel it is missing some features that other (hosted) Git servers have. CI/CD for example. I did like the simplicity and ease of use, though.