How to Install Drone on macOS
Drone is a Continuous Integration and Continuous Deployment (CI/CD) platform that enables developers to automate software testing and deployment processes. In this tutorial, we will show you how to install Drone on macOS.
Prerequisites
- macOS operating system
- Docker Desktop for macOS installed
- Homebrew package manager installed
- Git installed
Step 1 - Install Drone CLI
Open a terminal window and run the following command to install the Drone CLI:
brew install drone-cli
The drone-cli is a command-line interface that allows you to interact with Drone and manage your builds.
Step 2 - Create a Drone Configuration File
Create a .drone.yml file in your project root directory to define your workflow. This file contains instructions for building, testing and deploying your application. Here is an example configuration file:
kind: pipeline
name: default
steps:
- name: build
image: node:12
commands:
- npm install
- npm run build
- name: test
image: node:12
commands:
- npm test
- name: deploy
image: plugins/ssh
settings:
host: example.com
username: deploy
password:
from_secret: ssh_password
port: 22
target: /home/deploy/app
source: dist/
This configuration file defines three steps:
buildstep builds the project using thenode:12image.teststep runs the project's tests using thenode:12image.deploystep deploys the project using theplugins/sshimage.
You can customize the pipeline steps according to your project's requirements.
Step 3 - Install Docker Runner
To execute your pipeline, you need to have a Docker Runner. A Docker Runner is a lightweight container that runs your pipeline on your local machine or a remote server.
Run the following command to install the Docker Runner:
docker run -d \
-v /var/run/docker.sock:/var/run/docker.sock \
-e DRONE_RPC_PROTO=https \
-e DRONE_RPC_HOST=drone.example.com \
-e DRONE_RPC_SECRET=${DRONE_RPC_SECRET} \
-e DRONE_RUNNER_CAPACITY=2 \
-e DRONE_RUNNER_NAME=${HOSTNAME} \
--restart always \
--name runner \
drone/drone-runner-docker:1
Here, replace the values of DRONE_RPC_HOST and DRONE_RPC_SECRET with your own values. The DRONE_RUNNER_CAPACITY specifies the number of pipelines that can run concurrently and the DRONE_RUNNER_NAME specifies the name of the runner.
You can run multiple runners on different machines or use Drone's managed runner to scale your pipelines.
Step 4 - Connect Drone to Git
To connect Drone to your Git repository, you need to create a Drone App on your Git provider and obtain an access token. Follow the instructions for your Git provider to create a Drone App and obtain an access token.
Here are the steps for connecting Drone to a GitHub repository:
- Go to your GitHub account settings and select Developer settings > Personal access tokens.
- Click on Generate new token, give it a name and select the repo and admin:repo_hook scopes.
- Copy the access token.
Run the following command to tell Drone to watch your repository:
drone repo add <username>/<repository>
Here, replace <username> and <repository> with your own values.
Step 5 - Start the Drone Server
Run the following command to start the Drone Server:
docker run -d \
--volume=/var/run/docker.sock:/var/run/docker.sock \
--env=DRONE_GITHUB_SERVER=https://github.com \
--env=DRONE_GITHUB_CLIENT_ID=<github_client_id> \
--env=DRONE_GITHUB_CLIENT_SECRET=<github_client_secret> \
--env=DRONE_RPC_SECRET=${DRONE_RPC_SECRET} \
--env=DRONE_SERVER_HOST=drone.example.com \
--env=DRONE_SERVER_PROTO=https \
--restart always \
--publish=80:80 \
--publish=443:443 \
--name=drone \
drone/drone:1
Here, replace <github_client_id> and <github_client_secret> with the values of your GitHub App. The DRONE_SERVER_HOST specifies the domain name or IP address of your Drone instance.
By default, the Drone Server listens on ports 80 and 443. You can change the ports and use HTTP or HTTPS depending on your requirements.
Step 6 - Verify Installation
Open a web browser and go to https://drone.example.com (replace drone.example.com with your own domain name). You should see the Drone UI and your repository listed there.
Conclusion
Congratulations! You have successfully installed Drone on macOS and connected it to your Git repository. Now, you can create and manage pipelines to build, test and deploy your applications. We hope this tutorial was helpful. For more information, visit the official Drone documentation.