
Some checks failed
continuous-integration/drone/push Build is failing
- 删除了 .drone.yml 文件中的 npm test 命令 - 简化了构建流程,仅保留 npm run build 步骤
60 lines
1.2 KiB
YAML
60 lines
1.2 KiB
YAML
kind: pipeline
|
|
type: docker
|
|
name: nodejs-deploy
|
|
|
|
# 使用国内镜像加速
|
|
volumes:
|
|
- name: node_modules
|
|
host:
|
|
path: /usr/local/blackend/node_modules
|
|
- name: pnpm_cache
|
|
host:
|
|
path: /usr/local/blackend/pnpm_cache
|
|
|
|
steps:
|
|
- name: setup
|
|
image: node:22-alpine
|
|
depends_on: [clone]
|
|
volumes:
|
|
- name: node_modules
|
|
path: /drone/src/node_modules
|
|
- name: pnpm_cache
|
|
path: /root/.local/share/pnpm/store
|
|
commands:
|
|
# 配置镜像源
|
|
- npm config set registry https://registry.npmmirror.com
|
|
- npm install -g pnpm
|
|
- pnpm config set registry https://registry.npmmirror.com
|
|
# 安装pnpm
|
|
|
|
# 安装依赖
|
|
- pnpm install
|
|
|
|
- name: build
|
|
image: node:22-alpine
|
|
depends_on: [setup]
|
|
volumes:
|
|
- name: node_modules
|
|
path: /drone/src/node_modules
|
|
commands:
|
|
# 构建项目
|
|
- npm run build
|
|
|
|
- name: deploy
|
|
image: node:22-alpine
|
|
depends_on: [build]
|
|
commands:
|
|
# 启动服务
|
|
- npm start
|
|
environment:
|
|
NODE_ENV: production
|
|
PORT: 8001
|
|
|
|
# 触发条件
|
|
trigger:
|
|
branch:
|
|
- main
|
|
- develop
|
|
event:
|
|
- push
|
|
- pull_request |