Ruan Bekker's Blog

From a Curious mind to Posts on Github

Setup Gitea and Drone on Docker 2020 Edition

This post will show how to setup gitea and drone on a docker host with docker-compose. The drone example in this tutorial will be very basic, but in future posts I will focus more on pipeline examples using drone.

As this post I will use to link back for those who needs to setup the stack first.

Deploy Gitea and Drone

Get the docker-compose.yml:

1
$ wget -O docker-compose.yml https://gist.githubusercontent.com/ruanbekker/27d2cb2e3f4194ee5cfe2bcdc9c4bf52/raw/25590a23e87190a871d70fd57ab461ce303cd286/2020.02.04-gitea-drone_docker-compose.yml

Verify the environment variables and adjust the defaults if you want to change something, if you want your git clone ssh url to point to a dns name as well as the url for gitea, then change the following to your dns:

1
2
3
4
5
  gitea:
    ...
    environment:
      - ROOT_URL=http://gi.myresolvable.dns:3000
      - SSH_DOMAIN=git.myresolvable.dns

then deploy:

1
$ docker-compose up -d

Access your Stack

The default port for Gitea in this setup is port 3000:

image

Initial configuration will be pre-populated from our environment variables:

image

From the additional settings section, create your admin user (this user is referenced in our docker-compose as well)

image

Because I am using gitea as my hostname, you will be redirected to http://gitea:3000/user/login, if you don’t have a host entry setup for that it will fail, but you can just replace your servers ip in the request url and it will take you to the login screen, and after logging on, you should see this screen:

image

Access drone on port 80, you will be directed to the login screen:

image

Use the same credentials that you have used to sign up with gitea, and after logging on, you should see this:

image

If ever your login does not work, just delete the drone access token on gitea (gitea:3000/user/settings/applications)

Create a Git Repository

On gitea, create a new git repository:

image

You should now see your git repository:

image

Create a new file .drone.yml with the following content:

1
2
3
4
5
6
7
8
9
kind: pipeline
name: hello-world
type: docker

steps:
  - name: say-hello
    image: busybox
    commands:
      - echo hello-world

It should look like this:

image

Configure Drone

Commit the file in your git repository and head over to drone (which should be available on port 80) and select “Sync”, after a couple of seconds you should see the git repository:

image

Select “Activate” and “Activate Repository”, on the next screen select “Trusted”, verify that the configuration file name is the same as which we created, then select save:

image

Trigger the Build

If you click on “Activity Feed” you should see a empty feed. Head back to git and commit a dummy file to trigger the build to start. I will create a file name trigger with the value as 1 for my dummy file.

After committing the file, you will see on drone that the build started:

image

When we select the build, you can see we have a clone step and the step that we defined to echo “hello-world”:

image

Thank You

This was a basic introduction for gitea and drone, but I will use this post in conjunction with more gitea examples in the future.