Both gitea and drone is built on golang runs on multiple platforms including a raspberry pi and its super lightweight. Oh yes, and its awesome!
In this tutorial we will see how we can implement our own git service and cicd platform by setting up gitea and drone on docker and commit a python flask application to gitea and build a pipeline on drone.
Gitea: will be your self hosted git server
Drone Server: will be server being responsible for the web service, repositories, secrets, users, etc.
Drone Agent: will be the workers that runs your builds, jobs etc.
We will change our host’s ssh port to something else as our git server’s ssh method will be listening on port 22 and we would like to add our ssh key to gitea so that we can commit to our git server via ssh.
Change your server’s ssh port to 2222, by opening
/etc/ssh/sshd_config and edit the port to
2222 then restart sshd with:
Your ssh connection will still be established, but you can exit and ssh to your server by specifying the new port:
Make sure you have docker and docker-compose installed
Deploy Gitea and Drone
Below is the docker-compose file for our deployment. Note that we are running a postgres database which gitea will be configured on, you can also use other databases like mysql, sqlite etc. Visit their documentation for more info.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
Create the volumes path:
Create the external network:
Some key configuration,
SSH_DOMAIN will be the domain that gets used for things like cloning a repository. When you register your gitea account, you will use the same credentials to logon to drone.
Deploy your stack:
Register on Gitea
When your deployment is done, access your gitea server which should be available on
http://your-docker-ip:3000/ complete the registration, if you decide to go with postgres your username/password will be
postgres and your host will be
Make sure to complete the administrator account to get your admin credentials.
Setup SSH Key and Repo
Generate a ssh key that you will use for communicating to git over ssh. If you have already have an ssh key you can skip this step.
Login on gitea, once you are logged in, head over to profile / settings / ssh keys:
Add a new ssh key, go back to your terminal and copy the public key which we will provide to gitea:
Paste your public key and provide a descriptive title.
Head back to your dashboard and create your first repository:
It should look more or less like this:
Enable Repo on Drone
Head over to drone and select the repositores on the right hand side http://
Once its enabled head back to gitea.
Clone the repository
On your repository select ssh and copy the ssh link for your repository:
Then from your terminal add your private ssh key to your ssh agent and clone the repository:
1 2 3
Add Example Python Flask app to git
I will use a basic python flask application with some tests.
Let’s first add our pipeline definition for drone, so that drone understands how the pipeline should be run when gitea receives a commit:
1 2 3 4 5 6 7 8 9 10
Lets add that to git:
1 2 3
Our drone file should be in git, now our requirements dependency file for python:
1 2 3
Our blank file to make our application a module:
And our flask app:
1 2 3 4 5 6 7
Our tests directory and our python init file:
Now that we have all our files ready, commit and push to git:
1 2 3
Look at Drone Running
Head over to drone and look at the builds, you should see your build running at
If everything ran as expected you should see that it passed.
Build Status Badges
You can also include the build status badges from drone which will look like:
You can use the drone api:
1 2 3 4 5
Overall gitea and drone is really amazing and quite impressed with it, especially from the low memory footprint and that its so easy to work with.
Have a look at this for more resources: