Community Blog Setting Up Continuous Integration on Alibaba Cloud with Drone

Setting Up Continuous Integration on Alibaba Cloud with Drone

This article shows how you can use Drone for building and testing a sample project hosted in a Git repository on Alibaba Cloud.

By Alex, Alibaba Cloud Community Blog author.


In the current landscape, Drone is one of the most popular continuous integration and delivery platforms. Written in Go and based on Docker, Drone is intimately compatible with various version control services. It supports building, testing, and delivery of software automatically along with updates to codebase.

There are two options for running Drone, a hosted version of the folks or to run it on one's own servers, as shown in this tutorial later. This article illustrates how to use Drone for building and testing a sample project hosted in a Git repository on an Alibaba Cloud ECS instance running Ubuntu 16.04.

Drone Functions

Drone optimizes the comprehensive environment for building, testing, and deploying applications. It functions as a bridge between Jenkins and TravisCI. The following elaborates Drone functionality in detail.

  1. Drone's web-based interface enables retrieving and executing projects hosted securely on a Git repository in a seamless and straightforward method.
  2. It automates the required setups on ECS instances to run applications on Git using configurations in a drone.yml file available in the app.
  3. It fetches new updates to the codebase that has been pushed to Git repository, creates a new Docker image and runs the setup on ECS.
  4. It runs the image that may result in any of the three scenarios - successful build, a new release binary formed or a successful deployment. Subsequently, the Docker image is not required anymore, and it is reset in readiness for the next build and run.

In the next step, let's explore the requirements for this tutorial.

Tutorial Requirements

The first step is to install Drone and link it to a Git repository. As a prerequisite, ensure your Alibaba Cloud ECS instance that is running Ubuntu 16.04 is up and running. Next, install and configure Docker and Docker Compose on the ECS instance. Also, install Docker and Docker Compose, Nginx, and if necessary, use an SSL certificate for more security.

Install Docker and Docker Compose

To begin with, install Docker on the server by running the command below.

sudo apt-get install docker.io
sudo service docker restart

Secondly, install Docker Compose as it supports multi-container applications and helps to build Docker images from Dockerfiles.

sudo apt-get install -y docker-compose 

Configure SQLite

Drone uses SQLite database to store data regarding configurations. Run the command below to setup SQLite drivers.

sudo apt-get install libsqlite3-dev

Install Drone

Now, install Drone by running the following commands.

wget downloads.drone.io/master/drone.deb 
dpkg -i drone.deb

Next, install the Drone CLI as shown below.

curl -L https://github.com/drone/drone-cli/releases/download/v1.0.7/drone_linux_amd64.tar.gz | tar zx
sudo install -t /usr/local/bin drone

Note: The drone CLI enables you to interact with Drone via the command line. However, it's not necessary if you do not intend to use the command line for that purpose.

Create a GitHub Profile for Drone Service

Now, visit Github to register an app for the Drone service. Fill out all the information in the form below, including a callback URL.


A callback URL is under the Drone configuration and receives the repository's secret key to pull updates. The URL would look like - http://IP_ADDRESS/api/auth/github.com.

Post app registration, two important fields that become accessible are Client ID and Client Secret.


With both these fields, access the Drone configuration as shown below.

sudo nano /etc/drone/drone.toml 

Navigate to the specific section of the file with the following fields.

# [github]
# client="77871db82df3c6aff244"
# secret="8781fd562513b69932ff1b429fd4faf8c87637f5"
# orgs=[]
# open=false

Copy the Client ID and Client Secret from GitHub and paste them in the respective fields listed above. Save the changes and exit the editor.

Server Configurations

To make Drone operational, you need several configurations on the server as well as Drone. Start with accessing the /etc/drone/drone.toml file as shown below.

sudo nano /etc/drone/drone.toml 

The drone web interface uses port 80 as the default port. Change it to a different value if required.

Next, configure an email or SMTP server to receive notifications via email. Also, install Postfix as the mail server.

apt-get install postfix

In the /etc/drone/drone.toml file, access the section with the following fields and insert respective values.

# [smtp]
# host=""
# port=""
# from=""
# user=""
# pass=""

Now, let's implement some configurations on the firewall. The objective is to make the port 80 accessible to other computers on the network via the HTTP protocol.

sudo ufw allow http

Docker Configuration for Drone

Drone uses Docker to build images thus, there is a need to configure a Docker worker for Drone. Again, access the Drone configuration by executing the following command.

sudo nano /etc/drone/drone.toml 

Navigate to the section shown below.

# [worker]
# nodes=[
#   "unix:///var/run/docker.sock",
#   "unix:///var/run/docker.sock"
# ]

Drone configuration is very easy as it requires pasting simple items in the file or commenting in some parts. In case of more than one build running concurrently, increase the comments in the section as shown below:


Note: There is no limit on the number of builds running concurrently.

Restart Drone

After implementing all the necessary installations and configurations, restart Drone so that the changes are in effect.

service drone restart

Finally, execute the following command to set Drone to run automatically at system boot.

update-rc.d drone defaults

Testing Drone's Continuous Integration

For this step, log in to the Drone account and click on the option to activate repositories. With this, all repositories saved in the respective Git account become accessible.


The above snapshot shows only one repository (created earlier in the tutorial) in the GitHub account. Activate it using the toggle on the right hand (it flips between grey and green). On opting to activate a repository, Drone checks for updates to the project base using the GitHub API.

After activating the repository above, go to the Dashboard for the next part of the tutorial. The newly activated repository reflects on the left-hand as below.


Next, for any status information to be available on the Drone Dashboard, you must run the build. Access the drone-ssh repo as shown in the screenshot below. This page provides access to numerous features and settings applicable to the Git repository.


Trigger a new build by adding a project file using the Create new file button. Click on updates to assign the file name and write anything to it.


Now, commit the new file using the given button.


As you commit the new file, GitHub notifies Drone via the Git API, and initiate a new build process. The Drone Dashboard reflects the ongoing build process. The following screenshot shows the executed process.


With this, the build process for the drone-ssh project finishes successfully. The downward arrows have information regarding the particular step, if required. Also, refer to the Clone section to access information on how Drone fetches the build source code.

This successfully completes the continuous integration process with Drone.

Drone Configuration File

Drone relies on the .drone.yml file in the repository root. Below is a sample file that shows a typical configuration.

    image: golang
      - go build
      - go test
    mem_limit: 1000000000

Drone: The Bright Side

Some positive aspects of using Drone for continuous integration include:

  1. It is highly secure. However, it involves a tedious process of copying SSH keys across locations.
  2. Drone relies on an extremely potent method of handling project integrations using its .drone.yml configuration file.
  3. It offers ease creating production-like Docker images in the server.
  4. It is robust in terms of deployment owing to pre-integration with services such as Heroku and HipChat, among others.
  5. With its seamless support for services, Drone allows to fetch Docker images required to support the existing run. A practical example of this is the creation of a MySQL database service as well as the execution of tests to verify integration that results in seamless Drone deployments.

Drone: The Dark Side

The drone has the following two key negative aspects:

  1. The caching system is still a work in progress and may create operational issues. Nonetheless, it is still miles ahead of competitors such as Jenkins. Moving ahead, With continuing community improvement, expect resolution of such issues.
  2. The other aspect is poor documentation.


The tutorial covers some of the basic Drone methods ranging from configurations using (.drone.yml) file to building and testing GitHub repositories. It highlights the Drone's ease of use as compared to the other CI platforms. Unlike tedious and error-prone configurations of competing systems, Drone is clean and quite fluid. One of the other key elements is the ease of testing code owing to Docker integration, which makes it very important for continuous integration requirements. For more details, refer to the Drone documentation.

Don't have an Alibaba Cloud account? Sign up for an account and try over 40 products for free worth up to $1300. Get Started with Alibaba Cloud to learn more.

0 0 0
Share on


53 posts | 8 followers

You may also like