Skip to content

Instantly share code, notes, and snippets.

@xpepper
Last active August 25, 2016 22:28
Show Gist options
  • Save xpepper/9280633 to your computer and use it in GitHub Desktop.
Save xpepper/9280633 to your computer and use it in GitHub Desktop.
Setting up drone with docker
image: ruby2.0.0
script:
- cp config/database.example.yml config/database.yml
- bundle install
- psql -c 'create extension hstore;' -U postgres -h 127.0.0.1
- psql -c 'create role exmu with superuser login;' -U postgres -h 127.0.0.1
- psql -c 'create database exmu_test;' -U postgres -h 127.0.0.1
- bundle exec rake db:test:prepare
- bundle exec rspec spec
services:
- postgres:9.1
- elasticsearch dockerfile/elasticsearch 9200
# /etc/init/drone.conf
start on (filesystem and net-device-up)
chdir /var/lib/drone
console log
script
DRONED_OPTS="--port=:80"
if [ -f /etc/default/$UPSTART_JOB ]; then
. /etc/default/$UPSTART_JOB
fi
/root/go/bin/droned $DRONED_OPTS
end script

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 if you want an easy way to do that, or follow this guide.

Than add these two lines in your .profile

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.

# chmod +x start-droned.sh
$GOPATH/bin/droned --log.debug=true --datasource=/var/lib/drone/drone.sqlite --port=:80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment