# https://www.yisu.com/zixun/15849.html
# https://docs.drone.io/server/provider/gitlab/
version: '3'
services:
  drone-server:
    restart: always  ## 容器自动重启
    image: drone/drone:2
    container_name: drone-server-cloudnative
    networks:  ## 使用自定义网络，也可以不写
      - drone-net-cloudnative
    ports:
      - "9901:80"  ## 映射到宿主机的端口
    volumes:
      - ./data:/var/lib/drone
    environment:
      - DRONE_SERVER_HOST=192.168.31.249:9901  ## 端口需要和映射至宿主机的一致
      - DRONE_SERVER_PROTO=http 
      - DRONE_RPC_SECRET=7e52616bc93b86d114f95de534011d82 ## openssl rand -hex 16 自动生成

      # true 表示允许注册，false 表示关闭注册功能，此时只有 DRONE_ADMIN 中指定的账户才能登录
      - DRONE_OPEN=true
      # Drone 外网地址
      - DRONE_HOST=https://drone.windymuse.site
      # - DRONE_HOST=http://192.168.31.249:9901
      # 使用 GitLab
      - DRONE_GITLAB=true
      # GitLab 的 Client ID
      - DRONE_GITLAB_CLIENT_ID=193b8ca7beee9bcaa5dd8540e85e0f967d94177a1b4956648c25a15f380a9cad
      # GitLab 的 Secret
      - DRONE_GITLAB_CLIENT_SECRET=103071657036dfacb44dedb049a2fd4a3cf874f16a4cf7af352641cf44edda61
      # GitLab 的 URL
      - DRONE_GITLAB_SERVER=http://192.168.31.249:8929
      # 设置admin权限，以使用Trusted功能
      # https://blog.csdn.net/qq_35425070/article/details/106822146
      # https://blog.csdn.net/qq_35425070/article/details/106822191
      - DRONE_USER_CREATE=admin:true,token:gLBwGdBXUCTri6gEDDsLZW0ekoZqfcpq
  drone-runner-docker:
    restart: always  ## 容器自动重启
    image: drone/drone-runner-docker:1
    container_name: drone-runner-docker-cloudnative
    networks:
      - drone-net-cloudnative
    ports:
      - "9902:3000"  ## 映射到宿主机的端口，用于提供web页面，显示任务执行情况，可不映射
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_RPC_PROTO=http
      - DRONE_RPC_HOST=drone-server-cloudnative
      - DRONE_RPC_SECRET=7e52616bc93b86d114f95de534011d82 ## 与server服务中保持一致
      - DRONE_RUNNER_NAME=docker-worker
      - DRONE_RUNNER_CAPACITY=2
      - TZ=Asia/Shanghai 
      - DRONE_DEBUG=true
      #- DRONE_LOGS_DEBUG=true
      #- DRONE_LOGS_TRACE=true
      #- DRONE_UI_USERNAME=admin   ## runner的web页面用户信息
      #- DRONE_UI_PASSWORD=password 
    depends_on:
      - drone-server

networks:   ## 可以不自定义
  drone-net-cloudnative:
    driver: bridge
