Remark:
Use docker-compose to install and integrate gitlab, prepare environment docker docker-compose gitlab
1. docker-compose
version: '3'
services:
drone-server:
image: drone/drone:0.8
ports:
- 8080:8000
- 9000
volumes:
- ./drone:/var/lib/drone/
restart: always
environment:
- DRONE_OPEN=true
- DRONE_HOST=http://10.15.0.66:8080 # 参考drone 配置
- DRONE_GITLAB=true
- DRONE_GITLAB_CLIENT=1e4484a41fc6bbc8504c79b629b8d3eaf8eb6bc902b13b984618e5e6360cabc5
- DRONE_GITLAB_SECRET=748192aa5a3fda23f1a6891039bb453f068d91102ff66a29d9656cde10a551ef
- DRONE_GITLAB_URL=YOUGITLAB
- DRONE_SECRET=appdemo
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=appdemo
备注: 上面的gitlab client secret 在gitlab 进行配置即可,这样就能集成gitlab 的认证以及访问了
2. Start the run
备注: 我集成了jenkins
a. Jenkinsfile
pipeline {
agent {
node {
label 'docker-66'
}
}
stages {
stage('docker-compose build') {
steps {
sh 'docker-compose build'
}
}
stage('docker-compose run') {
steps {
sh 'docker-compose up -d '
}
}
}
}
3. Create a build project
参考 https://github.com/rongfengliang/drone-appdemo
主要是 .drone.yml (测试比较简单,只是简单的构建以及以来包的下载,实际需要考虑,发布,部署)
pipeline:
backend:
image: golang
commands:
- go build
- go test
frontend:
image: node:6
commands:
- npm install
- npm test
4. Run && enable drone ci
Entering
http://dronehost:port
will jump to the gitlab authentication page, agree to the authorization, and start the project
5. Summary
It is more convenient for teams that use containers to develop, and gitlab itself also supports drone ci, which can be deeply integrated, flexible and simple to use.
6. References
http://docs.drone.io/installation/
http://docs.drone.io/getting-started/
https://github.com/rongfengliang/drone-appdemo