OUR BLOG

Self-Host CI/CD Pipelines: Automate Your Builds with Drone CI in 20 Minutes

ADMINISTRATOR · 4 MIN READ

Tired of GitHub Actions minute limits or GitLab Runner complexity? Self-host your CI/CD with Drone CI — a lightweight, container-native automation platform that gives you full control over your build infrastructure without the bloat.

Why Self-Host Your CI/CD?

Cloud CI/CD services are convenient until they aren't. Minute-based pricing punishes active projects, queued builds kill productivity, and your code runs on someone else's infrastructure. Self-hosting Drone CI gives you:

  • Unlimited builds — no per-minute pricing, no queue waits
  • Full privacy — your code never leaves your servers
  • Container-native — every build step runs in Docker containers
  • Simple YAML config — no complex Groovy or JSON schemas
  • Git integration — works with GitHub, GitLab, Gitea, and Bitbucket

What You'll Build

By the end of this guide, you'll have a fully functional Drone CI server that automatically builds, tests, and deploys your applications on every git push. We'll configure it with Gitea (self-hosted Git) and deploy a sample application to demonstrate the pipeline.

Prerequisites

  • A VPS with at least 2GB RAM (4GB recommended for concurrent builds)
  • Docker and Docker Compose installed
  • A domain pointed to your server (for HTTPS)
  • 5 minutes of focused time

Step 1: Create the Docker Compose File

Create a directory for your Drone setup and a docker-compose.yml file:

version: "3.8"

services:
  drone-server:
    image: drone/drone:2
    container_name: drone-server
    ports:
      - "8080:80"
      - "8443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./data:/data
    environment:
      - DRONE_GITEA_SERVER=https://git.yourdomain.com
      - DRONE_GITEA_CLIENT_ID=your-gitea-client-id
      - DRONE_GITEA_CLIENT_SECRET=your-gitea-client-secret
      - DRONE_RPC_SECRET=your-rpc-secret-here
      - DRONE_SERVER_HOST=ci.yourdomain.com
      - DRONE_SERVER_PROTO=https
      - DRONE_USER_CREATE=username:admin,admin:true
    restart: unless-stopped

  drone-runner:
    image: drone/drone-runner-docker:1
    container_name: drone-runner
    depends_on:
      - drone-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_RPC_HOST=drone-server
      - DRONE_RPC_PROTO=http
      - DRONE_RPC_SECRET=your-rpc-secret-here
      - DRONE_RUNNER_CAPACITY=2
      - DRONE_RUNNER_NAME=docker-runner
    restart: unless-stopped

Step 2: Configure Gitea OAuth

Drone authenticates through your Git provider. For Gitea:

  1. Go to your Gitea instance → Settings → Applications → OAuth2 Applications
  2. Create a new application with redirect URI: https://ci.yourdomain.com/login
  3. Copy the Client ID and generate a Client Secret
  4. Update these values in your docker-compose.yml

Step 3: Generate Secrets

Create a strong RPC secret that the server and runner will share:

openssl rand -hex 32

Use this same value for DRONE_RPC_SECRET in both services.

Step 4: Launch Drone CI

docker compose up -d

Verify both containers are running:

docker ps | grep drone

You should see drone-server and drone-runner containers healthy.

Step 5: Configure Your First Pipeline

In your project repository, create a .drone.yml file:

kind: pipeline
type: docker
name: default

steps:
  - name: test
    image: node:18-alpine
    commands:
      - npm install
      - npm test

  - name: build
    image: node:18-alpine
    commands:
      - npm run build
    depends_on:
      - test

  - name: docker-publish
    image: plugins/docker
    settings:
      repo: registry.yourdomain.com/myapp
      tags: latest
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
    depends_on:
      - build

trigger:
  branch:
    - main
  event:
    - push

Step 6: Add Secrets

In the Drone web UI, go to your repository → Settings → Secrets and add:

  • docker_username — your registry username
  • docker_password — your registry password or token

Step 7: Activate the Repository

In Drone's web interface:

  1. Log in with your Git credentials
  2. Find your repository in the list
  3. Click "Activate"
  4. Push a commit to trigger your first build

Verification

Check that everything works:

  1. Visit https://ci.yourdomain.com — you should see the Drone dashboard
  2. Push a commit to your repository
  3. Watch the build execute in real-time in the Drone UI
  4. Verify the Docker image was pushed to your registry

Advanced: Multi-Stage Deployments

For production deployments, extend your pipeline:

  - name: deploy-staging
    image: appleboy/drone-ssh
    settings:
      host: staging.yourdomain.com
      username: deploy
      key:
        from_secret: ssh_key
      script:
        - docker pull registry.yourdomain.com/myapp:latest
        - docker compose up -d
    when:
      branch:
        - develop

  - name: deploy-production
    image: appleboy/drone-ssh
    settings:
      host: prod.yourdomain.com
      username: deploy
      key:
        from_secret: ssh_key
      script:
        - docker pull registry.yourdomain.com/myapp:latest
        - docker compose up -d
    when:
      branch:
        - main

Next Steps

Now that your CI/CD pipeline is running, consider these enhancements:

  • Add caching — mount volumes for node_modules, Maven, or pip caches to speed up builds
  • Matrix builds — test against multiple Node.js or Python versions simultaneously
  • Notifications — integrate Slack, Discord, or email for build status alerts
  • Self-hosted registry — pair with a private Docker registry for complete control
  • Monitoring — add Uptime Kuma to alert you if Drone goes down

Self-hosting your CI/CD pipeline eliminates build queue anxiety and gives you complete control over your development workflow. With Drone's container-native approach, every build is reproducible, isolated, and fast. Your future self will thank you when you're not waiting for cloud runners to free up.

© 2026 SYS BRIX LLCUSE ← → TO CHANGE TABINTELLIGENCE. INTEGRATED.
Self-Host CI/CD Pipelines: Automate Your Builds with Drone CI in 20 Minutes | Sys Brix