develop
Gong 2023-08-29 13:04:30 +08:00
parent c91607f130
commit c3b0de0739
2 changed files with 72 additions and 7 deletions

56
.drone-非docker.yml Executable file
View File

@ -0,0 +1,56 @@
# 项目的.drone.yml 文件
kind: pipeline # 定义一个管道
type: docker # 定义管道类型
name: build-test1 # 定义管道名称
# 声明宿主机 映射到 drone执行器的数据卷
volumes:
- name: node_modules # 数据卷名称
# Host Volume, 挂载到宿主机上的卷轴
host:
# 宿主机的绝对路径
path: /home/gite/drone/cache/node_modules
# 已经不需要共享此卷轴了
# - name: web_build
# host:
# path: /home/git/drone/web_build/test1
# path: /usr/share/nginx/test1
steps:
- name: build-project # 构建项目步骤
image: node:16.13.1 # 使用镜像和版本
depends_on: [clone] # 依赖 clone 步骤,
volumes: # 当前步骤使用(挂载)的卷轴
- name: node_modules # 数据卷名称
path: /drone/src/node_modules # 容器内的绝对路径
# - name: web_build
# path: /drone/src/dist
# 执行的命令
commands:
- pwd # 查看当前目录
- npm config set registry https://registry.npm.taobao.org # 切换淘宝镜像
- npm install # 安装依赖
- npm run build # 执行构建指令
# - tar -zcvPf tmp.tar.gz /drone/src/dist/* # 有打包需要再打包
- name: deploy-project # 上传文件步骤
image: appleboy/drone-scp
depends_on: [build-project] # 依赖 build-project 步骤,
settings:
# 服务器地址, 账号, 密码
host: o2packs.com # 不使用secrets, 明文
username:
from_secret: deploy_username # 使用secrets
password:
from_secret: deploy_password
# 需要上传的文件 「需要相对路径, 如果用绝对路径会整条路径打包上传」
# source: ./dist # 单个
source: # 多个
# - !* # 全都忽略
- ./dist
# 上传的目录文件夹
target: /usr/share/nginx/test1
# ps: 移除的目录是test1, 将source所有中定义的所有内容放入test1目录中
rm: true
port: 22
command_timeout: 2m

View File

@ -37,22 +37,31 @@ steps: # 定义管道的执行步骤
# tags: latest
#
- name: build-start
- name: deploy-project
# depends_on: # 依赖build管道
# - build
image: appleboy/drone-ssh
settings:
host:
from_secret: ssh_ip
username:
host: gong.cool
user:
from_secret: ssh_username
password:
from_secret: ssh_password
command_timeout: 5m
port: 22
commands:
- cd /usr/local
- ls -a
script:
- echo ====开始部署=======
- docker pull gong921123/hyperf:latest
# - docker run -itd --name gong921123/hyperf -p 8001:80 -v /usr/local/var/www/hyperf:/code -v
# - /usr/local/docker/vloumn_nginx:/etc/nginx/conf.d -v /etc/hosts:/etc/hosts --privileged=true gong921123/hyperf:latest
# - docker rmi $(docker images | grep gong921123/hyperf | grep none | awk '{print $3}')
- echo ====部署成功=======
# docker run -itd --name gong921123/hyperf -p 8882:80 -v /usr/local/var/www/hyperf:/code -v
# /usr/local/docker/vloumn_nginx:/etc/nginx/conf.d -v /etc/hosts:/etc/hosts --privileged=true gong921123/hyperf:latest
# - name: start_container
# image: docker
# commands: