Drone 與gitlab集成使用
參考網址:http://docs.drone.io/installation/
http://docs.drone.io/install-for-gitlab/
下載Drone docker鏡像
docker pull drone/drone:0.8
docker pull drone/agent:0.8
Drone與gitlab集成
docker-compose運行Drone
version: '2'
services:
gitlab:
image: gitlab/gitlab-ce:latest
ports:
- 8929:80
- 2289:22
volumes:
- /media/xww/sda1/myproject/gitlab-ce/gitlab/config:/etc/gitlab
- /media/xww/sda1/myproject/gitlab-ce/gitlab/logs:/var/log/gitlab
- /media/xww/sda1/myproject/gitlab-ce/gitlab/data:/var/opt/gitlab
restart always
drone-server:
image: drone/drone:0.8
ports:
- 8381:8000
- 9000
volumes:
- /media/xww/sda1/myproject/drone:/var/lib/drone/
restart: always
environment:
- DRONE_OPEN=true
- DRONE_HOST=http://drone-server:8000
- DRONE_GITLAB=true
- DRONE_GITLAB_CLIENT=44aca6668e69a0134a818f0c71f6c5d8ad2a6fc7c108b9edb8029afb71e91ac3
- DRONE_GITLAB_SECRET=ab055dcb8cb39abca8787f180274e53ed6e4e3319278fd62a35641a8958773c9
- DRONE_GITLAB_URL=http://gitlab
- DRONE_GITLAB_SKIP_VERIFY=true
- DRONE_SECRET=engine123
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=engine123
Drone需要與gitlab處於同一個網絡,方可通信。docker-compose啓動Drone時,會生成一個網絡供drone-server和drone-agent使用。也可以單獨啓動一個gitlab處於該網絡。
docker run --detach \
--hostname gitlab.example.com \
--publish 8929:80 --publish 2289:22 \
--name gitlab \
--restart always \
--volume /media/xww/sda1/myproject/gitlab-ce/gitlab/config:/etc/gitlab \
--volume /media/xww/sda1/myproject/gitlab-ce/gitlab/logs:/var/log/gitlab \
--volume /media/xww/sda1/myproject/gitlab-ce/gitlab/data:/var/opt/gitlab \
--network dronedocker_default \
gitlab/gitlab-ce:latest
DRONE_GITLAB_CLIENT和DRONE_GITLAB_SECRET的獲取如下:
在gitlab的賬戶下點擊setting
點擊左側的applications,新增一個application
輸入name和Callback URL
save後會生成DRONE_GITLAB_CLIENT(Application Id)和DRONE_GITLAB_SECRET(Secret)的id