因為drone會啟動一個container:drone/git,它跑得IP跟ap_net的網段不同,以致於連線異常,所以這部份要調整runner的網路設定。
參考:
https://stackoverflow.com/questions/46277180/drone-ci-failing-on-clone-step
version: "3"
name: runner
services:
drone-runner:
image: drone/drone-runner-docker:1
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 3000:3000
environment:
- DRONE_RPC_PROTO=http
- DRONE_RPC_HOST=172.18.0.4
- DRONE_RPC_SECRET=xxxx
- DRONE_RUNNER_CAPACITY=2
- DRONE_RUNNER_NAME=my-first-runner
- DRONE_RUNNER_NETWORKS=ap_net
networks:
ap_net:
ipv4_address: 172.18.0.5
networks:
ap_net:
external: true
增加了一行:
- DRONE_RUNNER_NETWORKS=ap_net
就可以正常執行了。
腳本.drone.yml:
kind: pipeline
type: docker
name: default
steps:
- name: greeting
image: alpine
commands:
- echo hello
- echo world
很開心,終於完成這個案例。