DEV Community

Cover image for Self Hosting a Drone CI Instance
Corey Alexander
Corey Alexander

Posted on • Updated on • Originally published at

Self Hosting a Drone CI Instance

Drone Screenshot

This is Part 1 of a multiple part series diving into using Drone as a CI platform!
Here is a rough outline of what these series might look like. This is liable to change until each post is released!

  • Part 1: Self Hosting a Drone CI Instance (This post)
  • Part 2: Running tests on Drone CI and writing a basic .drone.yml file
  • Part 3: Advanced .drone.yml techniques
  • Part 4: Caching Dependencies on S3

Self Hosting a Drone CI Instance

I love continuous integration and have CI setup on most of my personal projects, even if it just runs some linters.

I previously was using CircleCI almost exclusively. They provide a great service, that is free for a decent bit of personal use. In this case 'a decent bit' of personal use is 1000 minutes a month for free. This is just under 17 hours, at 16.666.

However there were a few months were I was hitting up against that free limit and that led to my builds getting queued and slowed. So I started looking at my options. CircleCI offers paid plans so first I looked there, but unfortunately their first paid offering started at \$50 a month. [1] This offering seems more geared towards businesses, not personal developers so I kept exploring my options.

[1] At the time of writing it is actually $90 now, but they have a $23 plan coming soon

I've also been on a self hosting kick, and I recently rented a relatively big server in the cloud that was going mostly unused, so it was a perfect storm to look for self hosted CI options!

The option that I ended up with is Drone. I've been running my instance for a few months, and have recently migrated most (but not all) of my projects over from CircleCI.

Installing Drone

I already have Dokku running on my server (see my previous post about migrating to Dokku here), so I wanted to use that to install and manage Drone if possible. Luckily both of these are built on top of Docker, and so far have worked pretty well together. Already having a Dokku server up and running definitely gave me a head start in getting Drone running!

I created this pretty boring repo to help manage deploying with Dokku ( Basically this is just a simple repo that contain a single Dockerfile. This inherits from the official Drone image, and exposes the correct port. Now I can push this repo to Dokku, for it to manage my installation and networking for me.

Drone does rely on a few mounted volumes in Docker that I also had to configure in Dokku that was accomplished with the following commands

dokku storage:mount drone /var/run/docker.sock:/var/run/docker.sock
dokku storage:mount drone /var/lib/exampledrone:/data
Enter fullscreen mode Exit fullscreen mode

I am looking to potentially move this installation onto Kubernetes sometime soon and if I do I will make a follow post describing that.

Configuring Drone

Setting up Drone was also relatively painless thanks to their Documentation ( This is the docs for a single instance machine, like I am running with Dokku, and using Github as the repo source. Drone also supports GitLab, Gitea, Gogs and Bitbucket.

Once I created the correct Github credentials, I grabbed the two I needed and added them as the following ENV vars available to Drone: DRONE_GITHUB_CLIENT_ID, DRONE_GITHUB_CLIENT_SECRET.

Then there are only 2 other ENV vars that are required: DRONE_SERVER_HOST and DRONE_SERVER_PROTO where the host name and protocol go.
For instance here are my config for those two variables:
Enter fullscreen mode Exit fullscreen mode

I also have DRONE_RUNNER_CAPACITY=4, which means I can have 4 containers running in parallel.

As far as config goes this is all you need to get the app running πŸŽ‰

Booting the App and Logging In

Now we should be able to boot up and login to our self-hosted Drone instance!

Drone does not have any authentication of its own and relies entirely on OAuth from Github. I love this model cause it’s one less account to have to manage.

This means that the first thing you will have to do is login to Drone via Github and give it access to your repositories. After this you can use the Web UI to add specific projects to Drone!

Once you have a project added Drone will register for web-hooks with Github and kick off builds whenever there are pushes to your Github repo.

That is of course if you have a .drone.yml file setup in your repo.
Which, luckily, its gonna be the next post in this series! πŸ˜‰

** Banner Generated with the awesome Dev banner generator by @christopherkade, check out his post about it!

Top comments (3)

ercadev profile image
Erik Carlsson • Edited

Great article! For me the dokku storage:add <appname> command did not work. dokku storage:mount <appname> worked better. Dont know if we were using different versions.

coreyja profile image
Corey Alexander

Hey thanks for the comment!

I think your version is the correct one, thanks for the reminder to update this!

I actually made a video after this article and in the process realized I needed to tweak some of the commands but I don't think I ever got around to updating this post :facepalm:

coreyja profile image
Corey Alexander

I went ahead and got this post updated with at least the correct commands for the storage part! Thanks again for letting me know!