Drone is a continuous integration and delivery (CI/CD) platform that helps automate the testing and deployment of code changes. In this tutorial, we will show you how to install Drone on Ubuntu Server latest.
Before starting with the installation of Drone on Ubuntu Server, make sure the following requirements are met:
To install Drone, we need to install the Drone CLI first. The Drone CLI is a command-line interface that lets you interact with the Drone server.
Here are the steps to install the Drone CLI:
sudo curl -L https://github.com/drone/drone-cli/releases/latest/download/drone_linux_amd64.tar.gz | tar zx && sudo install -t /usr/local/bin drone
drone --version
You should see the version number of the Drone CLI displayed.
After installing the Drone CLI, we can now install the Drone server.
To install the Drone server, follow these steps:
sudo mkdir -p /var/lib/drone
sudo docker run -d \
--name=drone \
--restart=always \
-p 80:80 \
-p 443:443 \
-v /var/lib/drone:/data \
-e DRONE_GITHUB_SERVER=https://github.com \
-e DRONE_SERVER_HOST=<your-domain-name> \
-e DRONE_SERVER_PROTO=https \
-e DRONE_RPC_SECRET=<your-secret-key> \
drone/drone:latest
Replace <your-domain-name>
with your registered domain name and <your-secret-key>
with a secret key you generate.
sudo docker ps
You should see the drone/drone
container running.
Now that the Drone server is installed, we need to configure it to work with your repository.
To configure Drone server, follow these steps:
Copy the Client ID and Client Secret generated by GitHub for your OAuth application.
Run the following command to configure Drone server:
drone server config \
--docker-server=<your-docker-registry-server> \
--docker-username=<your-docker-registry-username> \
--docker-password=<your-docker-registry-password> \
--github-server=https://github.com \
--github-client-id=<your-github-client-id> \
--github-client-secret=<your-github-client-secret> \
--host=https://<your-domain-name> \
--secret=<your-secret-key>
Replace <your-docker-registry-server>
, <your-docker-registry-username>
, and <your-docker-registry-password>
with your Docker registry server, username, and password, respectively. Also, replace <your-github-client-id>
, <your-github-client-secret>
, <your-domain-name>
, and <your-secret-key>
with the respective values generated in step 1 and 2.
sudo docker restart drone
To enable Drone for your repository, we need to add a .drone.yml
file to the root of your repository.
Here is an example .drone.yml
file:
kind: pipeline
name: default
steps:
- name: build
image: docker:19.03
commands:
- docker build -t my-image .
- docker login -u $DOCKER_REGISTRY_USERNAME -p $DOCKER_REGISTRY_PASSWORD $DOCKER_REGISTRY_SERVER
- docker push my-image
Replace my-image
with your Docker image name and $DOCKER_REGISTRY_USERNAME
, $DOCKER_REGISTRY_PASSWORD
, and $DOCKER_REGISTRY_SERVER
with your Docker registry credentials.
After configuring the repository, we can test Drone by making a code change and pushing it to GitHub.
Here are the steps to test Drone:
Make a code change to your repository and push it to GitHub.
Go to your repository in the Drone web interface by visiting https://<your-domain-name>/<your-github-username>/<your-repo-name>
.
Verify that the build is queued and then executed.
Verify that the Docker image is built and pushed to your Docker registry.
Congratulations! You have successfully installed Drone on Ubuntu Server latest and configured it to work with your repository.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!