Spin up AWS server
- Ubuntu Server 14.04 LTS (HVM), SSD Volume Type – ami-fce3c696
- m3.medium
- 250MB magnetic storage
Install docker
ssh ubuntu@<aws-instance>
and install docker
Register github application
Go to github and register a new OAuth application using the following values:
- Application name Couchbase Mobile Drone CI
- Homepage URL http://ec2-54-163-185-45.compute-1.amazonaws.com
- Application description Couchbase Mobile Drone CI
- Authorization callback URL http://ec2-54-163-185-45.compute-1.amazonaws.com/authorize
It will give you a Client ID and Client Secret
Create /etc/drone/dronerc
config file
On the ubuntu host:
1 2 |
|
Configure Remote Driver
Add these values:
1 2 |
|
and replace client_id
and client_secret
with the values returned from github.
Configure Database
Add these values:
1 2 |
|
Run Docker container
1 2 3 4 5 6 7 8 9 |
|
Check the logs via docker logs <container-id>
and they should look something like this
Edit AWS security group
With your instance selected, look for the security groups in the instance details:
Add a new inbound port with the following settings:
- Protocol TCP
- Port Range 80
- Source 0.0.0.0
It should look like this when you’re done:
Verify it’s running
Paste the hostname of your aws instance into your browser (eg, http://ec2-54-163-185-45.compute-1.amazonaws.com
), and you should see a page like this:
Login
If you click the login button, you should see:
And then:
Activate a repository
Click one of the repositories you have access to, and you should get an “activate now” option:
which will take you to your project home screen:
Add a .drone.yml
file to the root of the repository
In the repository you have chosen (in my case I’m using tleyden/sync_gateway
, which is a golang project, and may refer to it later), add a .drone.yml
file to the root of the repository with:
1 2 3 4 5 6 |
|
Commit your change, but do not push to github yet, that will be in the next step.
1 2 |
|
Kickoff a build
Now push your change up to github.
1
|
|
and in your drone UI you should see a build in progress:
when it finishes, you’ll see either a pass or a failure. If you get a failure (which I did), it will look like this:
Manually triggering another build
In my case, the above failure was due to a dependency not building. Since nothing else needs to be pushed to the repo to fix the build, I’m just going to manually trigger a build.
On the build failure screen above, there is a Restart button, which triggers a new build.
Now it works!
Setup the Drone CLI
I could run this on my OSX workstation, but I decided to run this on a linux docker container. The rest of the steps assume you have spun up and are inside a linux docker container.
1 2 |
|
Go to your Profile page in the drone UI, and click Show Token.
Now set these environment variables
1 2 |
|
Query repos
To test the CLI tool works, try the following commands:
1 2 3 4 5 |
|