diff --git a/.drone.yml b/.drone.yml index 198d566..fdd2866 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,42 +1,61 @@ -kind: pipeline -type: docker -name: deploy -# -volumes: +kind: pipeline +type: docker +name: nodejs-deploy + +# 使用国内镜像加速 +volumes: - name: node_modules - host: + host: path: /usr/local/blackend/node_modules - - name: web_build_dir + - name: pnpm_cache host: - path: /opt/1panel/apps/openresty/openresty/www/sites/120.48.5.80/automated - - name: yarn_cache - host: - path: /usr/local/blackend/yarn_cache + path: /usr/local/blackend/pnpm_cache steps: - - name: build-project - image: node:22-alpine + - name: setup + image: node:22-alpine depends_on: [clone] - mirror: https://docker.1panelproxy.com - volumes: + volumes: - name: node_modules path: /drone/src/node_modules - - name: web_build_dir - path: /drone/src/dist - - name: yarn_cache - path: /usr/local/share/.cache/yarn/v6 - commands: - # - npm config set registry https://registry.npm.taobao.org - - npm install -g pnpm + - name: pnpm_cache + path: /root/.local/share/pnpm/store + commands: + # 配置镜像源 + - npm config set registry https://registry.npmmirror.com - pnpm config set registry https://registry.npmmirror.com - - pnpm install - - pnpm build - #- npm cache clean --force - # - npm install - # - npm run build:prod - + # 安装pnpm + - npm install -g pnpm + # 安装依赖 + - pnpm install --frozen-lockfile + + - name: build + image: node:22-alpine + depends_on: [setup] + volumes: + - name: node_modules + path: /drone/src/node_modules + commands: + # 构建项目 + - pnpm run build + # 运行测试 + - pnpm test + + - name: deploy + image: node:22-alpine + depends_on: [build] + commands: + # 启动服务 + - pnpm start + environment: + NODE_ENV: production + PORT: 8001 + +# 触发条件 trigger: branch: - - main + - main + - develop event: - - push \ No newline at end of file + - push + - pull_request \ No newline at end of file