kind: pipeline
type: docker
name: venue_reservation_manage

steps:
  - name: prepare
    image: node:18-alpine  # 继续使用Node 18
    volumes:
      - name: node-model
        path: /app/model
      - name: node-cache
        path: /app/cache
      - name: node-build
        path: /app/build
    commands:
      - npm install -g pnpm  # 安装pnpm
      - pnpm config set store-dir /app/model  # 设置pnpm存储目录
      - pnpm config set registry https://registry.npmjs.org  # 使用官方npm registry（更稳定）
      - pnpm install --frozen-lockfile  # 安装依赖（使用现有lockfile）
      - pnpm run build  # 构建项目
      - cp -r dist /app/build/
      - cp Dockerfile /app/build/
      - cp default.conf /app/build/
      - cp run.sh /app/build/

  - name: build
    image: plugins/docker
    volumes:
      - name: node-build
        path: /app/build
      - name: docker
        path: /var/run/docker.sock
    settings:
      dockerfile: /app/build/Dockerfile
    commands:
      - cd /app/build
      - chmod +x run.sh
      - sh run.sh
      - docker ps

volumes:
  - name: node-build
    host:
      path: /home/docker/drone/node/build
  - name: node-model
    host:
      path: /home/docker/drone/node/model
  - name: node-cache
    host:
      path: /home/docker/drone/node/cache
  - name: docker
    host:
      path: /var/run/docker.sock