This repository aims to help beginners to get started with Drone. Install it within minutes and start moving towards continuous integration. If you want to get full picture about using Drone CI in production and setting up continuous integration process for your product start from our blog post
Below we describe in details how to:
- Install Drone CI on development environment
- Install production ready Drone CI behind nginx proxy with optional SSL
If you plan to use Drone CI for your product feel free to copy this repository to your project and change as needed.
Please, note that we use version 0.5 of Drone, which is not finally released yet, so there can be some breaking changes eventually. The good news is that we've been using this version in production for two months already and haven't had any issues.
The first step to do is to go to the Github and register new OAuth application. If you want to try install drone on the local machine just use http://localhost:8000/authorize
as Authorization callback URL
. For the production environment replace http://localhost:8000
with your schema and domain name.
Once registered, you should have:
- Github client id
- Github client secret
You will need them for both, production and local drone versions.
Prerequisites:
Installing Drone CI:
- Rename
drone-example.env
intodrone.env
and set your github clientId, clientSecret as well as your github username - Run one command to start Drone CI:
./bin/start-local.sh
That's it! ./bin/start-local.sh
script uses docker-compose
to run Drone UI and Drone Agent. Environment variables from drone.env
are in the .gitignore
to keep your secrets out of github repository.
Note: When you first see Drone UI it will show Loading...
in the sidebar - don't worry, this is expected behavior. Just go to the to the Account from top right menu to enable drone for some of your github repositories. From here you can move over to this repository, which can help you get started shipping your product with Drone CI.
Deployment to remove server is done using Ansible - a simple automation tool. Deployment was tested on a brand new Digital Ocean Ubuntu 16.04 server. Some changes might required to run other linux distributives. Deployment steps includes:
- Docker installation
- Nginx proxy installation & configuration to work with Drone
- PostgreSQL installation for Drone to persist build information
- Running Drone & Drone CI inside Docker containers
- Optional configuration of SSL certificate
Prerequisites:
- Ansible
- Ubuntu 16.04 server & ssh access to that server
Installation steps:
- Update server ip in
deploy/hosts
file. If you are planning to use same server for both drone and nginx - just put same ip for both, drone & nginx targets. - Install Ansible role dependencies with one command:
./bin/install-ansible-dependencies.sh
- Update github application callback url to either point to your server ip address or your domain. For example:
http://ci.myapp.com/authorize
or justhttp://server_ip/authorize
. - Set server ip variable or domain name in
vars/main.yml
(nginx_drone_server_name
variable). - Update
drone_github_users
invars/main.yml
- a comma separated list of github users, who will be able to access your continuous integration server. - Rename
credentials-template.yml
intocredentials.yml
and update your github clientId, clientSecret as well as username and password for PostgreSQL database.
Once you done all above, run the following command:
./bin/setup-server.sh && ./bin/deploy-drone.sh
You should have Drone CI installed by now. The only step remaining is to make Drone work behind Nginx proxy.
If you would like to install nginx on a same server with Drone CI - just run following command:
./bin/setup-nginx.sh
If you already have nginx installed somewhere else and just would like to attach drone nginx configuration to existing nginx server you can do following:
- Set nginx server ip in
hosts
file for the nginx target - Run same command
./bin/setup-nginx.sh
, but replyno
to the question about nginx installation.
In this case nginx configuration for Drone CI will be copied to the existing nginx server.
- Place your ssl keys into int ssl-keys directory as app.crt and app.key (they are in a
.gitignore
) - Make sure that
server_setup_ssl
is set to true invars/main.yml
- Deploy ssl using
./bin/setup-server.sh --tags "nginx"
- Update callback url in the Github application to start from
https
MIT