Drone on Power
Drone is a self-service Continuous Integration platform built on container technology that empowers busy teams to automate their build, test and release workflows using a powerful, cloud native pipeline engine. It integrates seamlessly with multiple source code management systems, including GitHub, GitHub Enterprise, Bitbucket, and GitLab.
Drone natively supports multiple operating systems and architectures, including Linux x64, ARM, ARM64 and Windows x64. However, it does not have official support for ppc64le architecture yet. The aim of blog is to help the interested users build and set up Drone CI on Power.
Pre-requisites
- A standalone ppc64le VM
This example uses a ppc64le Centos 8.3 VM. You can use PowerVS service at IBM Cloud or Minicloud to get your ppc64le virtual machine.
- Install Docker
mkdir /root/docker; cd /root/dockerwget https://download.docker.com/linux/centos/8/ppc64le/stable/Packages/docker-ce-20.10.10-3.el8.ppc64le.rpmwget https://download.docker.com/linux/centos/8/ppc64le/stable/Packages/docker-ce-cli-20.10.10-3.el8.ppc64le.rpmwget https://download.docker.com/linux/centos/8/ppc64le/stable/Packages/docker-ce-rootless-extras-20.10.10-3.el8.ppc64le.rpmwget https://download.docker.com/linux/centos/8/ppc64le/stable/Packages/containerd.io-1.4.11-3.1.el8.ppc64le.rpmyum localinstall containerd.io-1.4.11-3.1.el8.ppc64le.rpm docker-ce-cli-20.10.10-3.el8.ppc64le.rpm docker-ce-20.10.10-3.el8.ppc64le.rpm docker-ce-rootless-extras-20.10.10-3.el8.ppc64le.rpmservice docker start
- Install Go
git clone https://github.com/rpsene/goconfig.gitcd ./goconfigsource ./go.sh install
- Install ngrok
wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-ppc64le.tgztar xvzf ngrok-stable-linux-ppc64le.tgz -C /usr/local/bin
After installing ngrok, sign up at https://dashboard.ngrok.com/signup. Go to Your Authtoken
section and execute the displayed command with token:
ngrok authtoken <token>
- Install below required dependencies
yum install gcc -y
yum install dnf-plugins-core -y
yum config-manager --set-enabled powertools
yum install glibc-static -y
Create OAuth Application
Using ngrok, create a publicly accessible domain name for Drone server on Power VM for port 80.
ngrok http 80
This will generate the server domain name which can be accessed publicly on Internet. Use this domain name to create OAuth application in GitHub as shown here.
Create a shared secret
Create a shared secret to authenticate communication between runners and your central Drone server. You can use openssl to generate a shared secret:
openssl rand -hex 16
Build Drone server binary
Before building Drone server binary, we have to add ppc64le support to linter which will be used by runners. I have already added Power support to linter in my forked repository. Execute below commands to make it available on your Power VM:
git clone https://github.com/snehakpersistent/drone-yaml.git
cd drone-yaml && git checkout ppc-support-testmv drone-yaml/ /usr/local/go/src/
Next, update below Go scripts in your Drone repository to point to “drone-yaml/yaml/linter” in the import section.
drone/operator/runner/runner.go
drone/trigger/trigger.go
The commands to build drone server binary are as follows:
git clone https://github.com/snehakpersistent/drone.gitcd drone && git checkout ppc-support-testexport GOOS=linux && export GOARCH=ppc64le./scripts/build.sh
This will generate drone server binary for ppc64le architecture at release/linux/ppc64le/
in your Drone repository.
Build Drone server image
Execute following command to build Drone server image for Power:
docker build -t drone-server:linux-ppc64le -f ./docker/Dockerfile.server.linux.ppc64le .
Start Drone server
Drone server can be configured using below environment variables:
1) DRONE_GITHUB_CLIENT_ID : GitHub OAuth Client ID generated after creating OAuth application.
2) DRONE_GITHUB_CLIENT_SECRET : GitHub OAuth Client Secret generated after creating OAuth application.
3) DRONE_RPC_SECRET : Shared secret generated in the previous step. This is used to authenticate the rpc connection between the server and runners. The server and runner must be provided the same secret value.
4) DRONE_SERVER_HOST : Your external hostname or IP address. In this tutorial, we will use the domain name generated by ngrok.
5) DRONE_SERVER_PROTO : Your external protocol scheme. This value should be set to http or https. In this tutorial, we will use http.
Execute below docker command to start the Drone server:
docker run \
— volume=/var/lib/drone:/data \
— env=DRONE_GITHUB_SERVER=https://github.com \
— env=DRONE_GITHUB_CLIENT_ID=<GitHub OAuth client id> \
— env=DRONE_GITHUB_CLIENT_SECRET=<GitHub OAuth secret> \
— env=DRONE_RPC_SECRET=<Shared secret> \
— env=DRONE_SERVER_HOST=<Server Domain name> \
— env=DRONE_SERVER_PROTO=http \
— env=DRONE_WEBHOOK_ENDPOINT=http://<Server Domain name>/hook \
— publish=80:80 \
— publish=443:443 \
— restart=always \
— detach=true \
— name=drone \
drone-server:linux-ppc64le
This will start the drone server container by using configuration passed through environment variables. You can check the docker container logs to ensure that the server has started.
docker logs <runner container id>
Now, you can access the Drone server UI at http://<Drone server domain>
. Sign up using your email id which is linked to GitHub and it will authenticate using the OAuth application that was created earlier.
Build Drone Docker runner image
git clone https://github.com/snehakpersistent/drone-runner-docker.gitcd drone-runner-docker./scripts/build.shdocker build -t drone-runner-docker:linux-ppc64le -f docker/Dockerfile.linux.ppc64le .
This will build docker runner image for ppc64le architecture.
Start Docker runner
Before starting docker runner, we need to build drone-git image for Power. This image will be used by Drone for cloning git repositories while executing pipelines.
git clone https://github.com/snehakpersistent/drone-git.gitdocker build -t drone-git:linux-ppc64le -f ./docker/Dockerfile.linux.ppc64le .
This image is also available at this quay repository.
Execute below command to start the docker runner container:
docker run --detach \
--volume=/var/run/docker.sock:/var/run/docker.sock \
--env=DRONE_RPC_PROTO=http \
--env=DRONE_RPC_HOST=<Drone server domain> \
--env=DRONE_RPC_SECRET=<Shared secret> \
--env=DRONE_RUNNER_CAPACITY=2 \
--env=DRONE_RUNNER_NAME=my-first-runner \
--env=DRONE_RUNNER_CLONE_IMAGE=quay.io/snehakpersistent/drone-git:linux-ppc64le \
--publish=3000:3000 \
--restart=always \
--name=runner \
drone-runner-docker:linux-ppc64le
This will start the docker runner container by using the configuration passed through environment variables. You can check the docker container logs to ensure that the runner can contact the server.
docker logs <runner container id>
Create a Drone Pipeline
Create a basic Drone pipeline repository in your GitHub as shown here. Update your pipeline configuration in the script .drone.yml. Note the os
and arch
values in the platform section. Also push trigger is activated on the main
branch.
After creating the pipeline repository, click the sync button on Drone dashboard to make sure the created repository is listed on the UI. Select the reflected pipeline repository and activate it. This will automatically generate a GitHub webhook on your pipeline repository which will be used for triggering pipeline on push event to your repository. You can also manually execute the pipeline on specific branch by clicking on New Build
button on UI.
That’s all folks! Now, we have the basic Drone CI setup up and running on Power. Thanks for reading. Hope this tutorial was helpful.