First, read this post: http://jipiboily.com/2014/from-zero-to-fully-working-ci-server-in-less-than-10-minutes-with-drone-docker

# Install Drone
To use the custom service (as I did with elasticsearch) you have to install drone from source using my fork (https://github.com/xpepper/drone) which BTW merges the work done by @yosssi (yosssi/custom-services).

## Install Go 1.2
So prepare to install Go 1.2: use [godeb](http://blog.labix.org/2013/06/15/in-flight-deb-packages-of-go) if you want an easy way to do that, or follow [this guide](http://technosophos.com/2013/12/02/go-1-2-on-ubuntu-12-10.html).

Than add these two lines in your .profile
```shell
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$PATH
```

## Install Drone from source
To install Drone from source, follow their guide: http://drone.readthedocs.org/en/latest/install.html#from-source. 
Remember though, the cloned repo should be https://github.com/xpepper/drone and it should be put under `go/src/github.com/drone` so that the `make` command can succeeed.

### Alternative installation
Executing `make install` will install drone in 
* `/usr/local/bin`
* `/etc/init/drone.conf`
* `/etc/defaults/drone`

While `make dpkg` will build the .deb package.

### Running drone as a non-root user

1. `groupadd docker`
2. `useradd --system -d /var/lib/drone -s /bin/false -G docker drone`
3. restart docker with `service docker restart`
4. add these lines in `/etc/init.drone.conf` (under `"console log"`)

```
setuid drone
setgid drone
```

## Running Drone
To run Drone easily, we symlinked the two binaries (drone and droned) 

```
ln -s $GOPATH/src/github.com/drone/drone/bin/drone $GOPATH/bin/
ln -s $GOPATH/src/github.com/drone/drone/bin/droned $GOPATH/bin/
```

To start Drone, we use the `start-droned.sh` script listed below.

### Drone SMTP configuration with GMAIL
To configure Drone to send email using a Gmail account, fill the `Settings` section with there values

* SMTP Server: `smtp.gmail.com`
* SMTP Port: `587`
* SMTP From Address: `<my_account>@gmail.com`
* SMTP Username and Password: `<my_account>@gmail.com` / `<my_password>`
  
Then follow this link to allow Drone to send mail: https://accounts.google.com/b/0/DisplayUnlockCaptcha

# Misc
Logs are under `/var/log/upstart/drone.log` and `/var/log/upstart/docker.log`.


# UPSTART

make install wires the upstart in /etc/init/drone.conf. You just need to provide custom configs by editing /etc/default/drone