Docker is great tool to management linux containers. It brings DevOps to next level, from development to production environment. And of course, before deploy anything to production, software should be tested carefully and automatically.
That’s why Drone, a new lightweight CI server built-on top Go lang and Docker, will help us to resolve the testing problems in simple and fast way.
This guide will assume you already have Docker and Docker Compose tool. And of course, root permission ;)
Step 1 : Clone my example docker-compose here : https://github.com/khanhicetea/drone-ci
$ git clone https://github.com/khanhicetea/drone-ci
Step 2 : Update your setting in
Step 3 : Run drone via docker-compose
$ source .env
Step 4 : Go to your Drone url (remember use https url), then authorize with Github provider.
In example repo, I created a sample
.drone.sample.yml file so you can follow the structure to create own file.
I will explain some basics here
This file consists 3 sections :
- clone : To clone the source code and prepare for
pipelinestep. This section will be run first
- services : Declare your docker services (databases, ip server) which source code connect to. This section will be run at sametime with
- pipeline : Testing pipe, where you put testing logic here.
pipeline, I made a example PHP testing through these steps :
- Check conflicts in code (grep for
- Run PHP linter in application codes
- Run Composer to install all dependencies
- Import testing database to mysql services (using
testdatabasehostname to connect service)
- Run testing script via
Then, notify testing result via Slack channel ! ;)
Lets automate all the things !