Drone: Add instructions to deploy on docker swarm

Created on 11 Dec 2017  路  5Comments  路  Source: drone/drone

Here's my try:

version: '3.3'
services:
  drone-proxy:
    image: dockercloud/haproxy
    ports:
      - "80:80"
    deploy:
      mode: global
    depends_on:
      - drone-server
    environment:
      - FORCE_DEFAULT_BACKEND=False
      - ADDITIONAL_BACKEND_FRONT=server srv drone-server:8000
      - EXTRA_FRONTEND_SETTINGS_80=default_backend FRONT

  drone-server:
    image: drone/drone:0.8.4
    ports:
      - "8000:8000"
      - "9000:9000"
    volumes:
      - type: volume
        source: drone
        target: /var/lib/drone
        volume:
          nocopy: true
    environment:
      - SERVICE_PORTS=8000
      - VIRTUAL_HOST=example.com
      - DRONE_OPEN=true
      - DRONE_HOST=https://example.com
      - DRONE_SECRET=xxxx
      - DRONE_GITLAB=true
      - DRONE_GITLAB_CLIENT=yyyy
      - DRONE_GITLAB_SECRET=zzzz

  drone-agent:
    image: drone/agent:0.8.4
    command: agent
    depends_on:
      - drone-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_SERVER=drone-server:9000
      - DRONE_SECRET=xxxx
    deploy:
      mode: global
      placement:
        constraints:
          - node.role == worker

volumes:
  drone:

The deployment is as follows:

docker stack deploy --compose-file docker-compose.yml drone

btw. deploying on multiple hosts is currently crippled in functionality as there's no way to limit jobs running on single host: https://github.com/drone/drone/issues/758 Ideally drone would adapt resource-based approach known from nomad.

Most helpful comment

I'll add my stack for use with Gitea and Traefik and Glusterfs:

version: "3.4"
services:
    drone-server:
        image: drone/drone:latest
        volumes:
            - drone_data:/var/lib/drone
        ports:
            - 9000
        environment:
            - DRONE_OPEN=true
            - DRONE_HOST=https://drone.mycompany.com
            - DRONE_GITEA=true
            - DRONE_GITEA_URL=https://git.mycompany.com
            - DRONE_SECRET=hahalol
        deploy:
            mode: replicated
            replicas: 1
            labels:
                "traefik.port": "8000"
                "traefik.enable": "true"
                "traefik.docker.network": "traefik-net"
                "traefik.frontend.rule": "Host:drone.mycompany.com"
        networks:
            - drone                                                                                                                                                                                                                            
            - traefik-net

    drone-agent:
        image: drone/drone:latest
        command: agent
        depends_on:
            - drone-server
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
        environment:
            - DRONE_SERVER=drone-server:9000                                                                                                                                                                                                   
            - DRONE_SECRET=hahalol
        networks:
            - drone
        deploy:
            mode: global


volumes:
    drone_data: 
        driver: hjdr4plugins/docker-volume-glusterfs

networks:
    drone:
        driver: overlay
        external: false
        attachable: true
    traefik-net:
        external: true

All 5 comments

I'll add my stack for use with Gitea and Traefik and Glusterfs:

version: "3.4"
services:
    drone-server:
        image: drone/drone:latest
        volumes:
            - drone_data:/var/lib/drone
        ports:
            - 9000
        environment:
            - DRONE_OPEN=true
            - DRONE_HOST=https://drone.mycompany.com
            - DRONE_GITEA=true
            - DRONE_GITEA_URL=https://git.mycompany.com
            - DRONE_SECRET=hahalol
        deploy:
            mode: replicated
            replicas: 1
            labels:
                "traefik.port": "8000"
                "traefik.enable": "true"
                "traefik.docker.network": "traefik-net"
                "traefik.frontend.rule": "Host:drone.mycompany.com"
        networks:
            - drone                                                                                                                                                                                                                            
            - traefik-net

    drone-agent:
        image: drone/drone:latest
        command: agent
        depends_on:
            - drone-server
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
        environment:
            - DRONE_SERVER=drone-server:9000                                                                                                                                                                                                   
            - DRONE_SECRET=hahalol
        networks:
            - drone
        deploy:
            mode: global


volumes:
    drone_data: 
        driver: hjdr4plugins/docker-volume-glusterfs

networks:
    drone:
        driver: overlay
        external: false
        attachable: true
    traefik-net:
        external: true

Here's my try, using less explicit environment variables in preparation for native secrets and configs support (#2223): https://gist.github.com/gesellix/0789d5c14f5e657b70b4bbc15f924a9f#file-docker-stack-yml

I am hesitant to add Swarm to the official drone documentation (at https://github.com/drone/docs) because, as part of the official documentation, would require me to provide commercial support for Swarm. This is not something I can commit to yet, but maybe one day in the future.

I therefore propose we we start one of these:
https://github.com/drone/awesome-drone

It is a great place to share community resources, tips, tricks, etc. Please consider creating a pull request to github.com/drone/awesome-drone and sharing your configurations. Cheers :)

@bradrydzewski last link is broken 馃槃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

phil-davis picture phil-davis  路  4Comments

bradrydzewski picture bradrydzewski  路  6Comments

bradrydzewski picture bradrydzewski  路  5Comments

jpillora picture jpillora  路  6Comments

josmo picture josmo  路  5Comments