How to deploy your code from sourceLair to DigitalOcean

This is a brief guide about deploying your code from SourceLair to DigitalOcean. It requires you to have already a project on SourceLair.

Preparing your Digital Ocean server

Create a new Droplet at Digital Ocean following this guide. We'll use Ubuntu, but your favorite OS will be fine.

Make sure your Droplet is up to date by running

sudo apt-get update && sudo apt-get upgrade -y

Install apache2 and git

If you're using Ubuntu, just type:

sudo apt-get update && sudo apt-get install -y git apache2

If you're using another OS, choose the package manager of your choice

You're ready to go!

Steps

1. Put SourceLair public keys to DigitalOcean

The first step is to install your SourceLair public key to your DigitalOcean server. To do that, log into your DigitalOcean server and then run the following command
curl https://keys.lair.io/username/install | bash
Don't forget to replace username with your username at SourceLair.

2. Create git and site directories on your server

In order to get our code working on our DigitalOcean server, we will need one directory to keep our files and one to keep our git data. Assuming that we're deploying a simple site to apache, we'll navigate to our home directory (cd ~) and then create our directory there (mkdir site.git). We'll keep our files in /var/www/html .

3. Initialize empty git repository

We will initialize an empty git repository in the site.git directory, by running
git init --bare site.git

4. Add a post-receive hook

Now we have to add a post receive hook, in order to deploy the latest pushed code to our DigitalOcean server. We will do this in two steps: