Drone 是一个轻量级,为容器构建的强大的持续交付平台。 Drone 以 Docker 镜像的方式在 Dockerhub 上打包和发布。
docker pull drone/drone:0.8
Docker Compose
这个章节提供了使用 docker-compose 安装 Drone 的基本步骤。下面的配置开启一个使用一个代理客户端(Agent)的 Drone 服务器:
version: '2'
services:
drone-server:
image: drone/drone:0.8
ports:
- 80:8000
volumes:
- /var/lib/drone:/var/lib/drone/
restart: always
environment:
- DRONE_OPEN=true
- DRONE_HOST=${DRONE_HOST}
- DRONE_GITHUB=true
- DRONE_GITHUB_CLIENT=${DRONE_GITHUB_CLIENT}
- DRONE_GITHUB_SECRET=${DRONE_GITHUB_SECRET}
- DRONE_SECRET=${DRONE_SECRET}
drone-agent:
image: drone/agent:0.8
command: agent
restart: always
depends_on:
- drone-server
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DRONE_SERVER=drone-server:9000
- DRONE_SECRET=${DRONE_SECRET}
Drone 可以整合多个版本控制系统,使用环境变量来配置。这个例子展示了 GitHub 的整合。
你需要在 GitHub 上注册 Drone 来获得 client 和 secret。认证回调URL (authorization callback url)应该填写 <scheme>://<host>/authorize
services:
drone-server:
image: drone/drone:0.8
environment:
- DRONE_OPEN=true
- DRONE_ORGS=dolores,dogpatch
- DRONE_ADMIN=johnsmith,janedoe
+ - DRONE_GITHUB=true
+ - DRONE_GITHUB_CLIENT=${DRONE_GITHUB_CLIENT}
+ - DRONE_GITHUB_SECRET=${DRONE_GITHUB_SECRET}
- DRONE_SECRET=${DRONE_SECRET}
Drone 在宿主机器上绑定了空间来持久化 sqlite 数据库。
services:
drone-server:
image: drone/drone:0.8
ports:
- 80:8000
+ volumes:
+ - ./drone:/var/lib/drone/
restart: always
Drone 需要知道它自己的地址。你因此必须提供 <scheme>://<hostname>
的地址。请忽略末端的 /
。
services:
drone-server:
image: drone/drone:0.8
environment:
- DRONE_OPEN=true
+ - DRONE_HOST=${DRONE_HOST}
- DRONE_GITHUB=true
- DRONE_GITHUB_CLIENT=${DRONE_GITHUB_CLIENT}
- DRONE_GITHUB_SECRET=${DRONE_GITHUB_SECRET}
- DRONE_SECRET=${DRONE_SECRET}
Drone 代理客户端需要访问宿主 Docker daemon。
services:
drone-agent:
image: drone/agent:0.8
command: agent
restart: always
depends_on: [ drone-server ]
+ volumes:
+ - /var/run/docker.sock:/var/run/docker.sock
Drone 代理服务器需要服务器地址来进行代理客户端和服务器的交流。
services:
drone-agent:
image: drone/agent:0.8
command: agent
restart: always
depends_on: [ drone-server ]
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
+ - DRONE_SERVER=drone-server:9000
- DRONE_SECRET=${DRONE_SECRET}
Drone 服务器和代理客户端使用一个共享密钥来认证交流。这个应为你选择一个随机的字符串,并不要公开。
services:
drone-server:
image: drone/drone:0.8
environment:
- DRONE_OPEN=true
- DRONE_HOST=${DRONE_HOST}
- DRONE_GITHUB=true
- DRONE_GITHUB_CLIENT=${DRONE_GITHUB_CLIENT}
- DRONE_GITHUB_SECRET=${DRONE_GITHUB_SECRET}
+ - DRONE_SECRET=${DRONE_SECRET}
drone-agent:
image: drone/agent:0.8
environment:
- DRONE_SERVER=drone-server:9000
- DRONE_DEBUG=true
+ - DRONE_SECRET=${DRONE_SECRET}
Drone 默认是关闭注册的。这个例子开放了指定 GitHub 组织的成员的开放注册:
services:
drone-server:
image: drone/drone:0.8
environment:
+ - DRONE_OPEN=true
+ - DRONE_ORGS=dolores,dogpatch
- DRONE_HOST=${DRONE_HOST}
- DRONE_GITHUB=true
- DRONE_GITHUB_CLIENT=${DRONE_GITHUB_CLIENT}
- DRONE_GITHUB_SECRET=${DRONE_GITHUB_SECRET}
- DRONE_SECRET=${DRONE_SECRET}
Drone 管理员需要在配置文件中设置:
services:
drone-server:
image: drone/drone:0.8
environment:
- DRONE_OPEN=true
- DRONE_ORGS=dolores,dogpatch
+ - DRONE_ADMIN=johnsmith,janedoe
- DRONE_HOST=${DRONE_HOST}
- DRONE_GITHUB=true
- DRONE_GITHUB_CLIENT=${DRONE_GITHUB_CLIENT}
- DRONE_GITHUB_SECRET=${DRONE_GITHUB_SECRET}
- DRONE_SECRET=${DRONE_SECRET}