If you are building your side project or startup and want to avoid spending too much money on popular commercial solutions like Travic CI (which costs $69/month), you can use your own self-hosted Drone CI on your laptop, AWS free tier, or any other servers.
Drone CI features:
- Multi-platform support
- Yaml-based configuration
- Multi pipelines and complex build step logic support
- Docker based
- Free
- Github, Gitlab, Bitbucket support
We will run Drone CI on a single host and using Github, but you could use a multimachine configuration or Kubernetes, and different VCS providers. Find more information here.
Get the Host
For the purposes of this test, we use an AWS EC2 free tier instance, but you can use whatever you want. To use our approach, follow these steps:
- Go to the AWS page;
- Add your SSH pub key to Key Pairs section on the EC2 page (to access your - instance via SSH);
- Create a new Ubuntu 18.04 free tier instance on AWS;
- Allow 80 and 443 ports for the Security Group of your instance; if it’s a fresh account, use launch-wizard-1, or find it in description of your EC2 instance.
Install Docker
You only need Docker to start using Drone. Just follow the instructions here. Check that you installed everything right by running “docker -v”.
root@ip-172-31-23-205:~# docker -v
Docker version 18.09.3, build 774a1f4
Create an OAuth Application
We use Github for examples, but you can also run it on Gitlab, Bitbucket, Gitea, and Gogs. More information here.
- Go to https://github.com/settings/developers and sign in to your personal account, if you have one, or set up an account if you don’t.
- Click “new oAuth app”.
- Fill out the form, as per the example below.
You can use the IP of your server or assign a domain to it to correctly fill this form. If you do this, you can use the Client ID and Client Secret in the next steps.
Install Drone
This is very simple, just use the following:
docker pull drone/drone:1
Followed by:
--volume=/var/run/docker.sock:/var/run/docker.sock \
--volume=/var/lib/drone:/data \
--env=DRONE_GITHUB_SERVER=https://github.com \
--env=DRONE_GITHUB_CLIENT_ID=652d1he1a62b6336bf0 \
--env=DRONE_GITHUB_CLIENT_SECRET=c8990176a4bfywe55ekj8c3cf6d0ffccb8e3a213e \
--env=DRONE_RUNNER_CAPACITY=2 \
--env=DRONE_SERVER_HOST=drone1.pixelpoint.io \
--env=DRONE_SERVER_PROTO=https \
--env=DRONE_TLS_AUTOCERT=true \
--env=DRONE_USER_FILTER=lnikell \
--env=DRONE_USER_CREATE=username:lnikell,admin:true \
--publish=80:80 \
--publish=443:443 \
--restart=always \
--detach=true \
--name=drone \
drone/drone:1
Using this configuration, Drone generates SSL certificates with Let’s Encrypt, which then lets us use https for accessing the Drone UI. Your user account will have admin privileges (DRONE_USER_CREATE), which you should lose to lock access to the server for anyone else(DRONE_USER_FILTER). You can find explanations of other variables here.
Your instance should now be up and running, simply log in and use it!
Define Your Pipeline
Once you have your Drone CI instance ready, it’s time to activate the repository and create your pipeline. First, find the repository using the search bar and activate it.
On the settings page, you can change your project visibility settings, add secrets(sensitive information required for build steps) or add a cron job.
Defining build steps and pipelines in Drone is a simple process. Just add to your repository .drone.yml file and use yaml syntax to describe the steps. Here’s a simple example:
kind: pipeline
name: default
steps:
- name: frontend
image: node
commands:
- npm ci
- npm run test:unit
The example above is also available here: https://github.com/lnikell/hello-world/tree/master
Now, when you push to the repository, it will trigger a new build on Drone CI.
But you can do much more, depending of the complexity of your project. Here are few typical things that this process can be used for:
- Sending Slack notifications
- Deploying to Kubernetes
- Pushing images to a Docker registry
- Running database or other service instances required for tests
- Running multiple pipelines and using multiplatforms
Drone is an everyday helper which greatly improves the stability, flexibility and ease when our team runs tests and deploys code. For more information about Drone CI, visit https://drone.io/ and check out our story about how did we make Drone 1.0 better.
Top comments (14)
Could you please describe why you prefer Drone over some of the other free solutions like Jenkins, Team city, Azure DevOps or Gitlab CI? I've been shopping around for a CI tool and haven't considered Drone before.
Hi Scott,
I used Jenkins, Team City as per free solutions, used Travis CI, and read about Gitlab.
To be clear Jenkins and Team City I used last time 2 years ago, so only could compare with that state of their development.
Jenkins I did not like from the first look, very ugly, totally not a user friendly, complicated configuration, so it always required involving Devops or some guys who had more experience with this in order to make even simple things.
Team City I found much better than Jenkins, but the configuration of pipelines and configuration of Team City itself was not easy for me. Lack of yaml files, on free version they had a limits for agents and number of projects inside, if you do microservices architecture you exceed it very fast.
Gitlab the moment I tried to research it there were no easy way to use Github and Gitlab CI. I personally keep all project in Github, I like it and Github for me plays also sort of portfolio, and I don't want move my projects somewhere else.
In Drone I found everything which were necessary for me
Thank you for taking the time to write such a detailed reply! I think I will have to look into Drone. Most of my experience has been with Team City and it does feel very clunky, as much as I love Jetbrains a lot of their products can be awkward. I hear Jenkins mentioned the most but it sounds like something I don't want to learn more about now! For some reason I don't like YAML a lot and prefer code )why I like Chef more than Ansible although I don't have a lot of deep experience with them), but I'll definitely consider this.
Hi,
1) It's light-weight which written in go-lang.
2) Writing Yaml file very simple and straight forward linux command.
3) Deployment is faster compare to Gitlab AutoDevOps.
4) UI look's simple
5) Presently we are using for deploying the Spring-Boot application for past one year.
6) Docker image is very small.
I agree. Simple and practice.
Hey Alex, what's up?
I have one question, I deploy Drone in my job, I didn't want to use Jenkins and I'm loving work with Drone.
But, I need one problem, when in pipeline use any plugin, doesn't function.
Do I need any runner?
Yes, you need a runner. You can find instructions for installing one here: docs.drone.io/runner/docker/instal...
Thanks Kyle,
I already use, now I have to addapt my yaml file to many branchs.
I set everything up until the point where you just jumped to "Your instance should now be up and running, simply log in and use it!". How do I "log in and use it"?
I am connected to an EC2 instance, and as far as I can tell, when I ran the big command to start the drone server it was successful. What do I do now?
What requirements are needed to run Drone?
It's very lightweight. You could run it even on raspberry pi. So in this example it was run on a AWS free tier which is very low performance instance but I was successfully run builds on it.
I started tinkering with it. It looks good
I hope you will enjoy it.
you left your client ID & secret out there....