Private Git hosting using Gogs on Amazon Lightsail

Table of Contents

There are many options for “private” Git hosting. I put “private” in quotes because private repos on Gitlab, Github, Bitbucket, etc. are still sitting on a server to which people I don’t know have access, so I considered other options.

I’ve been watching Gogs for a while and thought it would be fun to set up a server running Gogs for my private Git repos.

Gogs is “A painless self-hosted Git service” and is basically a Github clone. It’s written in Go, which means that it’s drop-dead simple to install just about anywhere. It’s just a single binary. This is way simpler than running something like Gitlab CE.

Here are my notes from setting up Gogs on Amazon Lightsail, proxied by nginx. This isn’t meant to be a tutorial or anything, it’s just a few quick notes about the process I went through to get things running.

Amazon Lightsail

I’m easily flumoxed by Amazon’s web services so I decided to give their Lightsail service a try. Lightsail is basically Amazon’s answer to the ease of running server instances on services like DigitalOcean. My first impressions are that it succeeds. A few clicks and I had a small Ubuntu 16.04 instance running.

Gogs

To install gogs I did the following from a shell in the new Lightsail instance…

Installed git.

$ sudo apt-get update
$ sudo apt-get install git

Downloaded Gogs.

To keep things simple, I installed the gogs binary from the gogs install page. I simply copied the link to the amd64 version, downloaded and extracted it.

Then in a browser I went to http://[my-ip]:3000/ and couldn’t connect. I discovered that Lightsail’s default firewall only allows access on ports 80 and 443 so I added a rule for port 3000 and there was the installation page. Easy as that. I chose to run Gogs using SQLite as a database since it’s zero-config and plenty for my single-user needs. After finishing the initial configuration I set up Gogs as a service and started it after editing gogs.service with my settings (user/group/etc.)