Drone搭建的CI/CD平台

Drone是一个现代化的持续集成和持续交付平台,可让繁忙的团队自动化其构建,测试和发布工作流程。 利用Drone的团队可以更频繁地发布软件,并且漏洞更少。

安装drone.server


docker run -dit \
	-v `pwd`/data/:/data/ \
	-p 10090:80 \
	-e DRONE_OPEN=true \
	-e DRONE_SERVER_HOST=drone.anorz.com \
	-e DRONE_DEBUG=true \
	-e DRONE_GIT_ALWAYS_AUTH=false \
	-e DRONE_GOGS=true \
	-e DRONE_GOGS_SKIP_VERIFY=false \
	-e DRONE_GOGS_SERVER=https://git.anorz.com \
	-e DRONE_PROVIDER=gogs \
	-e DRONE_DATABASE_DRIVER=sqlite3 \
	-e DRONE_SERVER_PROTO=http \
	-e DRONE_RPC_SECRET=dronerpcsercret \
	-e DRONE_SECRET=dronerpcsercret \
	--name drone.server \
	--restart=always \
	drone/drone

安装drone.runners

根据自己的需要选择【docker, ssh 方式最常用】 [docker]: docker pull drone/drone-runner-docker
[ssh]: docker pull drone/drone-runner-ssh

alpine 安装 ssh : apk add --no-cache openssh


#DRONE_RPC_PROTO 更新设置选择 http还是https还是其他协议

# docker 方式发布
docker run -d \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -e DRONE_RPC_PROTO=https \
  -e DRONE_RPC_HOST=drone.anorz.com \
  -e DRONE_RPC_SECRET=dronerpcsercret \
  -e DRONE_RUNNER_CAPACITY=2 \
  -e DRONE_RUNNER_NAME=drone.runner \
  -p 3000:3000 \
  --restart always \
  --name drone.runner \
  drone/drone-runner-docker


# ssh 方式发布
docker run -d \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -e DRONE_RPC_PROTO=https \
  -e DRONE_RPC_HOST=drone.anorz.com \
  -e DRONE_RPC_SECRET=dronerpcsercret \
  -e DRONE_RUNNER_CAPACITY=2 \
  -e DRONE_RUNNER_NAME=drone.runner \
  -p 3000:3000 \
  --restart always \
  --name drone.runner \
  drone/drone-runner-ssh

ssh方式 .drone.yml

	
kind: pipeline
type: ssh
name: default

server:
  host:
    from_secret: host
  user:
    from_secret: user
  password:
    from_secret: password

#clone:
#  disable: true

steps:

  - name: env
    commands:
      - source /etc/profile
      - go version
      - go env
      - curl --version
      - docker version
      - git version
  - name: build
    # 环境变量只能放在这个位置(name下方)
    environment:
      # 获取通知地址
      ALTER:
        from_secret: bark_url
      # app运行目录
      WORKSPACE:
        from_secret: workspace
    commands:
      - source /etc/profile
      - make proto
      - go mod tidy
      - cp app.yml.example app.yml
      - make build-linux
      - cp -r app-srv-api app.yml Dockerfile Makefile tpl $WORKSPACE
      - cd $WORKSPACE
      - make restart id=01
      # 更新成功通知
      - curl -sS $ALTER | jq

# ci/cd 

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×