安装drone记录

无道 2021-06-05 2 条评论 教程相关 阅读106 手机阅读

安装

version: '3'
services:
  drone-server:
    restart: always
    image: drone/drone:1
    ports:
      - "10003:80"
    volumes:
      - ./data/drone/:/var/lib/drone/
      - ./data/data/:/data/
    environment:
      - DRONE_GITEA_SERVER=https://gitea服务器地址
      - DRONE_GITEA_CLIENT_ID=gitea生成的OAuth2客户端ID
      - DRONE_GITEA_CLIENT_SECRET=gitea生成的OAuth2客户端密钥
      - DRONE_SERVER_HOST=drone服务器地址
      - DRONE_SERVER_PROTO=https
      - DRONE_RPC_SECRET=自定义的Drone与runner通信密钥
  drone-runner-docker:
    restart: always
    image: drone/drone-runner-docker:1
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_RPC_PROTO=http
      - DRONE_RPC_HOST=drone-server
      - DRONE_RPC_SECRET=自定义的Drone与runner通信密钥

生成随机密码:

openssl rand -hex 16

ssh远程执行

- name: deploy
  image: appleboy/drone-ssh
  host: 127.0.0.1
  username: root
  password: Root密码
  port: 22
  script:
  - docker stop demo
  - docker rm demo
  - docker login --username=用户名 -p=密码 registry.cn-hangzhou.aliyuncs.com
  - docker pull registry.cn-hangzhou.aliyuncs.com/demo/demo:latest
  - docker run -d --name demo -p 80:80  registry.cn-hangzhou.aliyuncs.com/demo/demo:latest
  - docker rmi $(docker images | grep "none" | awk '{print $3}')

Docker编译

- name: build
  image: plugins/docker
  settings:
    username: 仓库用户名
    password: 仓库密码
    registry: registry.cn-hangzhou.aliyuncs.com
    repo: registry.cn-hangzhou.aliyuncs.com/demo/demo  #仓库完整路径
    context: src/
    dockerfile: src/Dockerfile  #Dockerfile相对Git根目录地址
    tags: latest

Golang

type: docker
kind: pipeline
name: build-go-disk

workspace:
  base: /go
  path: code

environment:
  APP_NAME: go_disk

steps:
  - name: build
    image: golang:1.16
    environment:
      GONOPROXY: gitee.com
      GOPRIVATE: gitee.com
      GONOSUMDB: gitee.com
    commands:
      - export GO111MODULE=on
      - export GOPROXY=https://goproxy.cn
      - go mod tidy
      - echo $(pwd)
      - export GOOS=linux
      - export GOARCH=arm64
      - go build -o $APP_NAME main.go
      - ls -la
      - chmod +x $APP_NAME
  - name: scp files
    image: appleboy/drone-scp
    settings:
      host: xxx
      port: 111
      username:
        from_secret: ssh_user
      password:
        from_secret: ssh_pass
      command_timeout: 2m
      target: /code/go/search2
      source:
        - go_disk
        - go.mod
  - name: restart
    image: appleboy/drone-ssh
    settings:
      host: xxx
      port: 111
      username:
        from_secret: ssh_user
      password:
        from_secret: ssh_pass
      command_timeout: 2m
      script:
        - cd /code/go/go_disk
        - app stop
        - sleep 1
        - app start

Vue配置

kind: pipeline
type: docker
name: build-template

workspace:
  base: /node
  path: code

steps:
  - name: build
    image: node:12.18.2
    commands:
      # 出于一些不可告人的原因使用了淘宝npm镜像 你不要笑
      - npm config set registry https://registry.npm.taobao.org
      - npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/
      - npm config set electron_mirror https://npm.taobao.org/mirrors/electron/
      - npm i
      - npm run build
      - pwd
      - ls -la
  - name: scp files
    image: appleboy/drone-scp
    settings:
      host: xxx
      port: 222
      username:
        from_secret: ssh_user
      password:
        from_secret: ssh_pass
      command_timeout: 2m
      target: /usr/local/nginx/html/template.misiai.com
      source: dist/*
  - name: move
    image: appleboy/drone-ssh
    settings:
      host: xxx
      port: 222
      username:
        from_secret: ssh_user
      password:
        from_secret: ssh_pass
      command_timeout: 2m
      script:
        - cd /usr/local/nginx/html/template.misiai.com
        - \cp -rf ./dist/* ./
        - rm -rf ./dist/
全文完 [
有帮助?打赏
支付宝打赏
微信打赏
]
标签: drone ci cd ci/cd
修改: 06月05日 11:19
上一篇: 安装Gitea记录
下一篇: 没有下一篇啦~

@[194],对啊,就是个备忘录,下次要重新安装的时候好快点。

v2的自己备忘就行了....哈哈

你这是学习笔记啊~~

V2的怎么加密了?

评论已加载完毕啦~
点击刷新/生成验证码