How to Install Drone on Ubuntu Server Latest

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.

Prerequisites

Before starting with the installation of Drone on Ubuntu Server, make sure the following requirements are met:

Step 1: Install Drone CLI

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:

  1. Open a terminal window on your Ubuntu Server.
  2. Run the following command to download and install the latest 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
  1. Verify that the Drone CLI is installed correctly by running the following command:
drone --version

You should see the version number of the Drone CLI displayed.

Step 2: Install Drone Server

After installing the Drone CLI, we can now install the Drone server.

To install the Drone server, follow these steps:

  1. Run the following command to create a folder for the Drone server:
sudo mkdir -p /var/lib/drone
  1. Run the following command to download and start the Drone server:
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.

  1. Verify that the Drone server is running by running the following command:
sudo docker ps

You should see the drone/drone container running.

Step 3: Configure Drone Server

Now that the Drone server is installed, we need to configure it to work with your repository.

To configure Drone server, follow these steps:

  1. Go to your repository on GitHub and create a new OAuth application with the following values:
  1. Copy the Client ID and Client Secret generated by GitHub for your OAuth application.

  2. 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.

  1. Restart the Docker container for the Drone server with the following command:
sudo docker restart drone

Step 4: Configure Repository

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.

Step 5: Test Drone

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:

  1. Make a code change to your repository and push it to GitHub.

  2. Go to your repository in the Drone web interface by visiting https://<your-domain-name>/<your-github-username>/<your-repo-name>.

  3. Verify that the build is queued and then executed.

  4. 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!