Nowadays git is the default versioning management system on the enterprise, and on personal / open source projects, it is for me and as far as I know other companies it is for all of them exept by one.
Companies have several options on how to host their git repositories. A really good option is to pay one of the incredibly great services provided online such as the outstanding Github or Bitbucket which both offer really good capabilities at low prices for startups and scales as you need more repos or developers. It really scales to high prices for big companies, but big enterprises usually have big budgets.
Companies are very jealous about their codebase and many don't want their code to be hosted on the cloud. Yes they create cloud based applications, cloud based platforms, sell
cloud as the magic word to customers, etc, but at the moment of truth ... they want their code in-house (sic).
One solution to this 'problem' is again use Github, in this case Enterprise Edition, or Atlassian Stash installed on your server, of course this options are much more expensive and prices scale rapidly.
On the other hand to paliate this budget issue you have several open source options at no expense being gitolite the most widely spread and the simplest as well.
But we are going to talk about another option, not so well known for the mainstream, Gitlab which in fact is a paid in-house service as well but comes with a Community Eddition that can cover most of the use cases perfectly.
Gitlab not only comes with a preinstalled git repository and a useful web front-end to manage it (handy for non technical people, product owners, project leaders, and bossess in general) but it even comes with a Continuous Integration service (gitlab-ci)!
As Gitlab team itself comments:
Git repository management, code reviews, issue tracking, activity feeds and wikis.
So we're going to start by installing Gitlab CE on a Vagrant box but it could be done on any machine. In a future posts we'll manage repositories and use the Continuous Integration server.
scriptDir = File.dirname(__FILE__) Vagrant.configure(2) do |config| config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" config.vm.box = "ubuntu/trusty64" config.vm.hostname = "Gitlab" config.vm.network "forwarded_port", guest: 80, host: 8080 config.vm.network "private_network", ip: "10.10.10.10" config.vm.provider "virtualbox" do |vb| vb.customize ["modifyvm", :id, "--memory", "2048"] vb.customize ["modifyvm", :id, "--cpus", "1"] vb.customize ["modifyvm", :id, "--name", "Gitlab"] vb.customize ["modifyvm", :id, "--cpuexecutioncap", 30] vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] vb.customize ["modifyvm", :id, "--ostype", "Ubuntu_64"] end config.vm.provision "shell" do |s| s.path = scriptDir + "/bootstrap.sh" end end
Nothing special with this Vagrantfile exept for the shell provisioning provided in
bootstrap.sh file which contains the necessary instructions to install Gitlab, lets have a look at it:
#!/usr/bin/env bash sudo apt-get purge xorg lxde xinit openbox lightdm sudo apt-get autoremove sudo apt-get clean sudo apt-get update -y sudo apt-get install -y vim curl openssh-server ca-certificates postfix &> /dev/null curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash sudo apt-get install gitlab-ce sudo gitlab-ctl reconfigure sudo gitlab-ctl status
In case you are not using an ubuntu based system head to https://about.gitlab.com/downloads/, there you have the instructions needed to modify the script for your distro.
With this two files in place you only need to
vagrant up and wait a fair amount of time, I'm saying more, a lot of time as the installation takes longer than I'd like. At the end you have a working Gitlab installation you can access directly on your browser and use user
root and pass
5iveL!fe to access your newly git repository manager. (Note I used 10.10.10.10 as IP for the box in Vagrantfile)
Now we're going one step further, imagine you are installing Gitlab not on a vagrant box but in an enterprise server of
fake-company.com in which you plan to give access to your users (developers) and start collaborating. In that case you need to configure Gitlab so it respond to your URL. For this purpose modify
/etc/gitlab/gitlab.rb file and change this parameter:
## Url on which GitLab will be reachable. ## For more details on configuring external_url see: ## https://gitlab.com/gitlab-org/omnibus-gitlab/blob/629def0a7a26e7c2326566f0758d4a27857b52a3/README.md#configuring-the-external-url-for-gitlab external_url 'http://fake-company.com'
No need of any extra configuration, just save the file and run
sudo gitlab-ctl reconfigure on your console. There is though a final step, as we're configuring Vagrant we need to tell our host where to find
http://fake-company.com so we add it to
/etc/hosts and we are set to browse to our Gitlab installation.