kind: pipeline type: docker name: drone-dev-db-bastion-vue # 触发器 trigger: # 触发分支 branch: - master # 触发事件 event: - push # 事件状态 status: - success # 共享目录 volumes: - name: node-cache host: path: /data/drone/node/cache - name: node-build host: path: /data/drone/node/build - name: docker-sock host: path: /var/run/docker.sock - name: env-files host: path: /niushuai233/env # ci 步骤 steps: # node install - name: node-package image: node:14.12.0 volumes: - name: node-cache path: /node_modules - name: node-build path: /app/build commands: - echo 'node package start' # 打包 - npm config set registry https://registry.npm.taobao.org -g - npm config set cache /node_modules --global - npm install - npm run build # 拷贝打包结果到宿主机 - mkdir -p /app/build/db-bastion-vue - cp -R dist/ /app/build/db-bastion-vue/ # 构建镜像 - name: build-image image: docker:dind volumes: - name: docker-sock path: /var/run/docker.sock commands: - echo 'build image start' # 构建新镜像 - docker build -t niushuai233/db-bastion-vue:latest . # 清理无用镜像 - docker image prune -f --filter "dangling=true" # 启动服务 - name: deploy image: docker:dind volumes: - name: docker-sock path: /var/run/docker.sock - name: env-files path: /niushuai233/env commands: - echo 'deploy start' - pwd - ls -alh - sh deploy.sh