Skip to content

A runner for Drone CI that runs jobs in Qemu virtual machines

License

Notifications You must be signed in to change notification settings

remram44/drone-runner-qemu

Repository files navigation

What is this?

Drone is an opensource CI server. It allows you to run commands when you push to a Git repository, for example to build a release, run your unit tests, or publish a website.

Drone relies on plugins called "runners" to do the actual command execution. It comes with runners for running on your machine (which is dangerous, commands in the repository could mess with your system) or on cloud platforms such as AWS and GCP.

For self-hosting purposes, being able to run on virtual machines locally is desirable for security, reproducibility, and cost. This is what this repository provides, using the QEMU open-source emulator.

Installation

Download some images:

$ qemu-images/download.sh

You can customize how images are run by editing the .qemu.sh scripts or making your own.

Download the qemu runner and configure to connect with your central Drone server using your server address and shared secret:

$ DRONE_RPC_HOST=drone.example.com \
  DRONE_RPC_PROTO=https \
  DRONE_RPC_SECRET=${SECRET} \
  DRONE_QEMU_IMAGE_DIR=$(pwd)/qemu-images \
  DRONE_QEMU_DEFAULT_IMAGE=ubuntu-22.04 \
  ./drone-runner-qemu

Or with Docker:

$ docker run -d \
  --device /dev/kvm \
  --env=DRONE_RPC_HOST=drone.example.com \
  --env=DRONE_RPC_PROTO=https \
  --env=DRONE_RPC_SECRET=${SECRET} \
  --env=DRONE_QEMU_IMAGE_DIR=/qemu-images \
  --env=DRONE_QEMU_DEFAULT_IMAGE=ubuntu-22.04 \
  --restart=always \
  --volume=$(pwd)/qemu-images:/qemu-images \
  --name=drone-runner-qemu ghcr.io/remram44/drone-runner-qemu

That's it. Go make some pipelines with type: qemu, they will be run by this system in their own, self-contained, ephemeral virtual machines.

Usage

Use type: qemu in your .drone.yml. You can set the top-level image key to the name of an image file. For example:

---
kind: pipeline
type: qemu
name: default

image: ubuntu-22.04

steps:
- name: greeting
  commands:
  - echo hello world

License

This software is licensed under the Blue Oak Model License 1.0.0.

Notice

This software relies on the runner-go module authored by Drone.IO, Inc under a Non-compete license. This module can be used in any software for free for any permitted purpose in accordance with the license. This module cannot be used in any software that competes with the licensor.