I love Github - they do so much right. But sometimes I don't want everything to be public and I also don't want to pay so my private repos can be hosted. Gitlab is the perfect answer to this situation - here's how to set it up in 5 minutes for $5/month.
This Kind of Thing Used To Be Hard
Not anymore. Services like Linode, Azure, AWS and DigitalOcean are making Virtual Machine creation ridiculously simple.
I use DigitalOcean for most of my VM/Image needs. It only runs Linux (for now) but if you're a Windows/.NET person Azure is hard to beat. If you use Linux from time to time - DigitalOcean is hard to beat.
Let's setup Gitlab. *The next few paragraphs are simple summaries of what you can read in this guide
Step 1: Get Yourself a Domain
Head over to DNSimple and sign up. This is one of the greatest services I've ever used - they manage all my domains for me. Come up with something - if you don't find a .com you'll likely find a .io domain - it takes seconds.
Step 2: Add an SSH Key
Just like with Github - you don't necessarily need to do this, but it really makes life simple for you when you do. Grab your key from
~/.ssh/id_rsa.pub and add it here.
Step 3: Create a Droplet
A sort of silly name for a VM in the sky, but who cares. Sign up with Digital Ocean and notice there's no recurring payment plan - you just pay for what you use when you use it.
Once you're signed up, head over to "Create Droplet". Enter a host name:
Then, down below, select the Applications tab. You'll see the usual suspects - we want to use Gitlab so select that. Finally, select our key, and leave the rest as a default.
Kick it live and watch how everything springs to life within 30 seconds.
Step 4: Setup Your Domain and Configure Gitlab
Once your image is created, grab the IP address from the settings and head back over to DNSimple. There, create an A record that points to "git.yourdomain.com". You can also make it a naked domain if you choose.
The nice thing here is that DigitalOcean's image is ready to roll and respond to any domain call for a given IP. There's no messing with NGinx/Apache - it's all ready to roll!
OK, now we need to SSH into our new Gitlab box and tell Gitlab what's up. You can read more here, in detail or you can simple edit these files:
Look for "gitlab_url" and set it to whatever domain you're using. Then
And in here, set the
gitlab: settings once again to point to your domain. In addition, head down and change the emails as needed.
Now, just restart Gitlab:
service gitlab restart
DigitalOcean set that up for you - isn't that groovy? You should see things restarting and all should be well. It might take a second or two for Unicorn to get going, but when it does...
Let's See That Beautiful Site!
Head over to your new Gitlab website! If you don't and you see a message that says "Bad Gateway" - that's because NGinx can't talk to Unicorn just yet. Refresh a few times and the site will pop up.
The login page should show right up and you log in with these credentials:
- login: firstname.lastname@example.org
- password: 5iveL!ife
You'll immediately be prompted to reset your password - take a second and do that. Then head over to your profile and change your email, etc.
Rock You Some Gitlab
Create a Project like you would at Github, then follow the instructions for the push URL, etc. It all just works, which is insane.
One thing that utterly amazes me about Gitlab is how close it feels to working with Github. So many great little touches - like adding "Closes #2" to your commit message will close an issue (yes, there's issue tracking as well).
You can view your repo as a set of files (displaying the README like Github does) or in a news view. It shows a beautiful set of graphs if you're working with others. You can define organizations that can see only a subset of repos.
It is a really well-done tool.
Do You Need To Do This?
I think so. Again: I love Github, but I love having the "meta" stuff (issues, tracking, people, etc) under my control. For $5/month (which is what this image costs) - I can easily do both and be happy about it.
There it is - took only 5 minutes... which still freaks me out.