Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Drone CI/CD Platform

Bo-Yi Wu
November 06, 2018

Drone CI/CD Platform

Drone is a Continuous Delivery platform built on Docker, written in Go

* Why I don’t choose Jenkins or GitLab CI?
* What is Drone CI?
* Drone Infrastructure
* How to install Drone in five minutes?
* Integrate your project
* Create your Drone plugin
* Try drone cli without drone server

Bo-Yi Wu

November 06, 2018
Tweet

More Decks by Bo-Yi Wu

Other Decks in Technology

Transcript

  1. Drone CI/CD Platform
    Drone is a Continuous Delivery platform built on Docker, written in Go

    2018/11/03

    View full-size slide

  2. Agenda
    • Why I don’t choose Jenkins or GitLab CI?

    • What is Drone CI?

    • Drone Infrastructure

    • How to install Drone in five minutes?

    • Integrate your project

    • Create your Drone plugin

    • Try drone cli without drone server

    View full-size slide

  3. About Me
    appleboy @
    appleboy @

    View full-size slide

  4. Jenkins Drone Travis Gitlab ci

    View full-size slide

  5. Why I leave Jenkins

    View full-size slide

  6. Why?
    • Complicated project setting

    • Write the plugin (Java language)

    • Maintenance?

    • Learning Curve?

    • Grow your team?

    View full-size slide

  7. Try the GitLab CI

    View full-size slide

  8. .gitlab-ci.yml config

    View full-size slide

  9. But Why I leave GitLab CI ?

    View full-size slide

  10. Why?
    1. GitLab Only
    2. Not extensible

    View full-size slide

  11. How to use SSH command

    View full-size slide

  12. https://florianbrinkmann.com/en/3473/deployment-gitlab-ci/

    View full-size slide

  13. Try drone-ssh tool
    https://github.com/appleboy/drone-ssh

    View full-size slide

  14. pipeline:
    ssh:
    image: appleboy/drone-ssh
    host: foo.com
    username: root
    password: 1234
    port: 22
    script:
    - echo hello
    - echo world
    proxy_host: 10.130.33.145
    proxy_user: ubuntu
    proxy_port: 22
    proxy_password: 1234
    custom key

    View full-size slide

  15. What is Drone?

    View full-size slide

  16. Drone CI
    • Container native CI/CD platform

    • Easy to install & maintain

    • Isolate builds

    • Simple YAML Configuration

    • Integrates with several VCS Providers

    • Rich set of official plugins (any container can be a plugin)

    • Execute locally with simple command (drone exec)

    • open source (https://github.com/drone/drone)

    View full-size slide

  17. Everything is a
    Docker Container

    View full-size slide

  18. Project CI/CD Flow
    git clone testing deploy notify

    View full-size slide

  19. Project List and Status

    View full-size slide

  20. Job detail and logs

    View full-size slide

  21. Isolate build

    View full-size slide

  22. Support Git Host

    View full-size slide

  23. Drone CI Infrastructure
    Agent
    Server
    Step 1
    git clone
    Step 2
    make build
    Step 3
    deploy app
    work space
    extra service
    Agent

    View full-size slide

  24. Support Platform
    https://blog.drone.io/drone-cloud-native-ci-cd-windows-containers/
    https://blog.drone.io/drone-announces-official-support-for-arm/

    View full-size slide

  25. services:
    drone-server:
    image: drone/drone:0.8
    ports:
    - 8080:8000
    volumes:
    - ./:/var/lib/drone/
    restart: always
    environment:
    - DRONE_HOST=${HOST}
    - DRONE_OPEN=true
    - DRONE_SECRET=drone-workshop
    - DRONE_ADMIN=appleboy
    # GitHub Config
    - DRONE_GITHUB=true
    - DRONE_GITHUB_CLIENT=${CLIENT}
    - DRONE_GITHUB_SECRET=${SECRET}
    SQLite DB

    View full-size slide

  26. drone-agent:
    image: drone/agent:0.8
    restart: always
    depends_on:
    - drone-server
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    environment:
    - DRONE_SERVER=drone-server:9000
    - DRONE_SECRET=drone-workshop
    - DRONE_MAX_PROCS=3
    drone agent count

    View full-size slide

  27. Auto scale drone agent
    https://github.com/appleboy/drone-on-kubernetes

    View full-size slide

  28. Agent
    Server
    Agent
    Agent Agent
    autoscaler
    https://github.com/drone/autoscaler

    View full-size slide

  29. Task - Agent
    drone_server=server:9000
    Task - Server
    port: 80/9000
    ECS - Fargate ECS - Service
    Target Group
    Port: 80
    Route 53 Service Discovery
    ALB / SSL
    Cloud Watch
    https://github.com/appleboy/drone-terraform-in-aws

    View full-size slide

  30. Deploy Flow in Golang
    Release
    Test
    Git Docker Notify

    View full-size slide

  31. Pipeline in Golang
    • Go Testing

    • Verify Quality

    • Build Binary

    • Deploy Binary

    • Build Image

    • Deploy Container

    • Send Notification

    View full-size slide

  32. workspace:
    base: /go/src
    path: github.com/go-ggz/ggz
    clone:
    git:
    image: plugins/git
    depth: 50
    tags: true

    View full-size slide

  33. Testing && Verify Quality

    View full-size slide

  34. pipeline:
    backend:
    image: golang:1.11
    pull: true
    commands:
    - cp .env.example .env
    - make embedmd
    - make fmt-check
    - make misspell-check

    View full-size slide

  35. Parallel processing

    View full-size slide

  36. build_linux_i386:
    image: golang:1.11
    pull: true
    group: build
    environment:
    TAGS: sqlite
    commands:
    - SERVICE=ggz-server make build_linux_i386
    - SERVICE=ggz-redirect make build_linux_i386
    build_linux_arm64:
    image: golang:1.11
    pull: true
    group: build
    environment:
    TAGS: sqlite
    commands:
    - SERVICE=ggz-server make build_linux_arm64
    - SERVICE=ggz-redirect make build_linux_arm64

    View full-size slide

  37. Build Docker

    View full-size slide

  38. publish_linux_amd64:
    image: plugins/docker
    group: release
    pull: true
    repo: goggz/ggz-server
    dockerfile: dockerfile/server/Dockerfile
    secrets: [ docker_username, docker_password ]
    default_tags: true
    when:
    event: [ push, tag ]
    local: false
    Docker plugin for Drone CI/CD

    View full-size slide

  39. Secret Security

    View full-size slide

  40. Notification Plugin

    View full-size slide

  41. Write Drone Plugin
    Whether you prefer language
    PHP, Ruby, Bash, Go, Python

    View full-size slide

  42. Three Steps
    •Program with your language

    •Build Docker Image and Testing

    •Upload to Docker Hub

    View full-size slide

  43. Prefix PLUGIN_

    View full-size slide

  44. Testing in Local

    View full-size slide

  45. Try Drone without Server
    drone exec

    View full-size slide

  46. https://www.udemy.com/devops-oneday/?couponCode=DRONE-DEVOPS

    View full-size slide

  47. Any Question?

    View full-size slide