编程语言/Drone/rsync:修订间差异
来自康健生活
创建页面,内容为“== 标题文本 == <syntaxhighlight lang="javascript"> - name: deploy image: drillster/drone-rsync # 使用宿主机网络 network_mode: host settings: hosts: # 服务器地址 - localhost user: root key: from_secret: deploy_ssh_secret port: 22 source: dist/ target: /home/app-website</syntaxhighlight>” |
|||
| 第1行: | 第1行: | ||
== 标题文本 == | == 标题文本 == | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
- name: deploy | # 编译阶段 | ||
- name: build | |||
image: node:23 | |||
volumes: | |||
- name: node_modules | |||
# 挂载到容器内的路径 | |||
# 宿主机 node_modules -> 挂载到容器/drone/src/node_modules目录 | |||
path: /drone/src/node_modules | |||
# - name: pnpm-cache | |||
# path: /drone/src/.pnpm-store | |||
commands: | |||
- echo "============构建前的文件===============" | |||
- pwd | |||
- ls -alt | |||
- echo "======================================" | |||
- yarn --version || npm install -g yarn | |||
- yarn install --frozen-lockfile | |||
- yarn build | |||
- echo "============构建后的产物===============" | |||
- ls -la dist || exit 1 | |||
- name: deploy | |||
image: drillster/drone-rsync | |||
# 使用宿主机网络 | |||
network_mode: host | |||
settings: | |||
hosts: | |||
# 服务器地址 | |||
- localhost | |||
user: root | |||
key: | |||
from_secret: deploy_ssh_secret | |||
port: 22 | |||
source: dist/ | |||
target: /home/app-website | |||
# 如果在同一个服务器,可以把代码直接编译进挂载目录或者移入挂载目录 | |||
# - name: deploy | |||
# image: alpine:latest | |||
# volumes: | |||
# - name: admin-website | |||
# # 在容器内提供target目录 挂载到宿主机的host目录下 | |||
# path: /target | |||
# commands: | |||
# - apk add --no-cache rsync | |||
# # 将容器内的dist目录同步到target目录,给volumes挂载 | |||
# - rsync -av --delete /drone/src/dist/ /target/ | |||
# # 验证文件是否复制成功 | |||
# - ls -la /target/ || exit 1</syntaxhighlight> | |||
2026年3月18日 (三) 17:04的版本
标题文本
# 编译阶段
- name: build
image: node:23
volumes:
- name: node_modules
# 挂载到容器内的路径
# 宿主机 node_modules -> 挂载到容器/drone/src/node_modules目录
path: /drone/src/node_modules
# - name: pnpm-cache
# path: /drone/src/.pnpm-store
commands:
- echo "============构建前的文件==============="
- pwd
- ls -alt
- echo "======================================"
- yarn --version || npm install -g yarn
- yarn install --frozen-lockfile
- yarn build
- echo "============构建后的产物==============="
- ls -la dist || exit 1
- name: deploy
image: drillster/drone-rsync
# 使用宿主机网络
network_mode: host
settings:
hosts:
# 服务器地址
- localhost
user: root
key:
from_secret: deploy_ssh_secret
port: 22
source: dist/
target: /home/app-website
# 如果在同一个服务器,可以把代码直接编译进挂载目录或者移入挂载目录
# - name: deploy
# image: alpine:latest
# volumes:
# - name: admin-website
# # 在容器内提供target目录 挂载到宿主机的host目录下
# path: /target
# commands:
# - apk add --no-cache rsync
# # 将容器内的dist目录同步到target目录,给volumes挂载
# - rsync -av --delete /drone/src/dist/ /target/
# # 验证文件是否复制成功
# - ls -la /target/ || exit 1
No categories