Did you ever want to have your own private GitHub-like repository where you can store your code and share them with others? Well, today, I will be discussing how to install a private GIT web app that takes only a few minutes to set-up. Writing this post will take longer than running this exercise.
GITLAB is a GITHUB clone built on RoR (Ruby on Rails). It is a web application designed to allow you to host your own private GIT repositories. You can go to their website and do the full install or simply install a VM appliance. It works great for storing code. It has some basic collaborative tools like sharing guests, issuing merge and issues. This is an ideal app for a small web or smartphone-app development team.
Installing via an VM appliance is the most painless way to go. No need to install a full Linux distro and setting it up.I use Turnkey Linux and you should too. It has a large library of pre-built appliances and GITLAB is one of them I use on a day-to-day basis. I have installed over four instances of GITLAB on my ESXi server.
Today, I am going to show you how easy it is to get your own private GIT repo server up in a few minutes running just VirtualBox.
Step 1. Download ISO or OVF from Turnkey Linux.
Step 2. Create New Guest inside VirtualBox
Step 3. Install, set passwords
Step 4. Reboot.
That is it.
Ok. this post was short on specifics but if you know what you are doing, you can see it only takes a few minutes. Now, there are some things to consider and I'll elaborate and you give you a more detail set of instructions in this second part of my post.
The Detailed Setup Instructions.
This is for Mac OSX and Linux users.
The most important thing about setting up a VM appliance is deciding what sort of networking you want to use. In VirtualBox and with GitLab (or any other Linux web app), there are only two choices: Bridge-Mode or Host Only. Do not use NAT mode.
Bridge Mode will make the guest act as another computer on your network. If you have a DHCP server, it will request an get an assigned IP address. The advantage to this is that the machine is available to others on your network. Your friends and colleagues can access your GIT server as well.
Host Only mode allows the host computer and guest to see each other. Only the computer running VirtualBox will see the guest. The advantage to this is if you work offline, say camping 2 weeks at Yosemite Park without WIFI, you can access your Virtual Guest. Unfortunately, since the guest does not have outside network access, it can't do things like send email notifications and the like.
Both have their advantages and disadvantages and their use case.
The second most important thing is Hostname. You need a domain name to use GITLAB. Do not rely on IP address because it may change. If you do not have a valid DNS name (one being issued by a DNS server on your network), you can fake it by using and modifying /etc/hosts.
This is what I do. My clients (be it OSX, Linux) only need to add an entry to the host file to see my GIT server. If you are hosting this on the Internet and have your own DNS name, this you don't need to worry about it.
In my example, I will be using localgit.local.
On my machines that need to access the GIT server, I add an entry with the IP address (either DHCP or static) and my fake DNS hostname, localgit.local
That is pretty much the only two important things you need to know.
Now for the full instructions.
After downloading the Turnkey Linux iso, you will need to create a Guest OS in VirtualBox.
Choose Linux & Debian for machine Type and version.
Specify the memory you want to use. 768MB- 1GB is enough.
Set the drive size you want. I default to 20-60GB depending on my needs and I use Thin provisioning (or let the drive dynamically allocate/grow).
Before starting up the VM, choose the ISO disk image to boot from
Next Step. Boot the VM and go through the install process.
A few notes. It will ask you how to partition the Virtual Drive. This is your call and preference. I use the second option, Guided, because it is quick. I prefer not to use LVM in the event I want to mount this virtual drive from another Virtual guest that doesn't support Linux LVM. It will guide you through the process, install the bootloader and reboot one more time before you can use it.
After the VM restarts, you can disconnect the .iSO disk image. This next process is a series of prompts from Turnkey for passwords and set-up.
You will be ask to enter
- root password
- mysql password
- password for admin account (to access web site)
- email address for admin account
Finally, you will be asked to enter the hostname/dns name for the GITLAB server. This is it.
Once finished, you will be shown a menu where you can view administrative links, change IP, reboot, etc. This concludes the installation of GITLAB.
If you are reading this, I assume you know the basics of GIT and how to connect to remote GIT repos.
It will be the same here, you will need to set up SSH keys. GITLAB's web interface allows you to copy-n-paste into the web browser which simply things. Some GIT apps don't even require you to generate SSH keys and generate unique ones within their respective apps.
You can migrate existing repos from your local machine and push them to GITLAB or create a new blank empty one within the web app.
As you can see here below, I can see my source code and view changes within the GITLab web interface.
It works surprisingly well with various GIT client's I've been using: SourceTree,GitBox on Mac OSX, Git-Cola, Giggle,GitG, and SmartGIT on Linux.