The Gogs Git-Server is a central repository for your private git projects. Usually, you wouldn't need a git server at all, or you would probably use GitLab. But GitLab can be a complex mess, so I was looking for an easy-to-use alternative. Other well-known git servers are e.g. Atlassian Bitbucket, Gitblit and GitList.
But aside from all those Gogs is the only one to be fast AND lightweight AND eays-to-use: Gogs is written in Googleʼs Go Programming Language which makes it really fast.
Choice of your Git-Servers: Aspects
The most important aspect of choosing a software was the choice of its infrastructure and its runtime environment. Criterias like software stack, ram usage etc. are considered here.
Web-Infrastructure for GitLab and GitList
GitLab is a complex ruby monster. You will need good knowledge of Rubys package manager, or you will fail. GitList is written in PHP, which I did not choose for two reasons: Performance (although PHP has made big steps in the past) and I did not want do configure a full blown web server like apache or nginx this time. Also, php needs to be configured as well...
Java-Standalone und Perl für Bitbucket
The commercial solutions name is Bitbucket and cannot be installed nor used for free. The stack is quite low on requirements, but not necessarily easy to acquire: Java 1.8 and Perl 5.8.8 are still considered modern technology -- especially looking at the corporate business sector.
Java Web Application Server Gitblit
Gitblit is a Java Web Application and thus shipped as either .war -File or as bundle containing the Jetty Web Application Server. Java web application servers can (but don't need to) be heavy weights, might be complicated and are another potential risk for errors and such. Also, they do create some overhead in process counts, ram usage etc.
I do know how to use web application servers very well, but this time I was looking for an even nicer solution. Also the web interface of Gitblit isn't the prettiest one.
Gogs Git-Server (Go Git Service)
So there is the Go Git Service (Gogs for short), which is written in Google Go as the name indicates,, making it very lightweight and easy on RAM. Gogs starts its own, integrated web service. Since static resources are served from a dedicated directory, you can (but don't need to) let those be served by an existing web server -- for example apache via mod_proxy or nginx using try_files.[caption id="attachment_5968" align="aligncenter" width="1008"]Gogs: Screenshot of the Dashboard[/caption]
There is also a nice and clean web interface -- GitHub, anyone? It is not completed yet, but it is fully functional and already has issues and diffs included. You can also use gogs git server without any external database -- SQLite is included.
So this time I decided to go for go(gs). ;-)
gogs on Uberspace
I also wanted to know if Gogs can be installed on Uberspace webhosting.
Use Apache httpd for serving static resources and proxying
Most configurations I saw just proxy or rewrite all requests to gogs. This is a pity, because Apache is optimized for serving static resources: It will compress static files and sets expires-headers. It will also care about your certificate. So the example given at Geeklabor and in this Blog where only a redirect/rewrite is being used is possible, but not optimal yet.A much nicer solution is a proxy directive, because apache httpd will be used to serve the ssl certificate (if any), static resources, apply compression and setting expire headers. A complete configuration (without looking at uberspace) might be the following:
You should also add directives for caching etc. -- see examples at h5bp. If you are going to use such a configuration on uberspace, you'd need to convert or apply corresponding directives to your .htacces -File. The alias and directory directes need to be rewritten to relative paths.
# Aliases for gogs
Alias /js "/var/www/vhost/gogs.example.invalid/public/js"
Alias /img "/var/www/vhost/gogs.example.invalid/public/img"
Alias /css "/var/www/vhost/gogs.example.invalid/public/css"
Alias /assets "/var/www/vhost/gogs.example.invalid/public/assets"
Alias /fonts "/var/www/vhost/gogs.example.invalid/public/fonts"
Alias /less "/var/www/vhost/gogs.example.invalid/public/less"
# No indexes by default
Allow From All
# because Alias can be used to reference resources outside docroot, you
# must reference the directory with an absolute path
# directives to effect the static directory
Require all granted
Allow from all
# Do not pass these aliases to the proxy.
ProxyPass /assets !
ProxyPass /img !
ProxyPass /css !
ProxyPass /js !
ProxyPass /fonts !
ProxyPass /less !
ProxyPass /config.codekit !
# Pass everything else.
ProxyPass / http://example.invalid:3000/
ProxyPassReverse / http://12140:3000/
Require all granted
Allow from all
Uberspace: reserve a portPorts are limited on shared hosting, if available at all. Thus, if you are going to use a high port, please read about using high ports on Uberspace first. An advantage on Uberspace is, that those ports are not exposed publicly -- you need to use your apache instance as a proxy, as seen above.
gogs on Windows
Gogs can administrate SSH keys, as you already know it from GitHub. If you are on windows however, you need to install a bash first, e.g. by installing cygwin. With this enabled, Gogs Git-Server is one of the few solution which will run on windows: GitLab (the most commonly used solution) will not run on Windows. While GitBlit on Windows is officially supported, a Java Runtime on Windows will almost certanly create performance issues (keywords: File system, multi threading, missing cgroups, memory allocation, etc.).[caption id="attachment_5973" align="aligncenter" width="622"]Gogs (Go Git-Server) on Windows.[/caption]
As the gogs install guide for windows explains, you can also make gogs git server a windows service. You can use nssm (non-sucking service manager) for this task. As your cansee from the (german) screenshot above, the service was started and restarted using nssm. I also used XAMPP to provide a MySQL database and an apache httpd as proxy using the config from above.
Gogs is a fast, reliable and beautiful server. It is not mature yet, but contains all important features you'd probably need for your private repository.
The project was written using the Google Go programming language and is super fast and easy on resouces like RAM.