当前位置:   article > 正文

【Drone】drone编译web端 防墙策略 | 如何在被墙的状态drone顺利编译npm

【Drone】drone编译web端 防墙策略 | 如何在被墙的状态drone顺利编译npm

一、drone编译防墙版本

1、web端drone

kind: pipeline
type: docker
name: ui
steps:
  - name: build_project
    image: node:20-slim 
    depends_on: [clone]
    volumes:
      - name: node_modules
        path: /drone/src/node_modules
    commands:
      - pwd
      - du -sh *
      - npm config set registry https://registry.npmmirror.com
      - npm install -g pnpm || npm install -g pnpm || npm install -g pnpm  # Retry logic
      - pnpm config set store-dir /drone/src/node_modules/.pnpm-store
      - pnpm install || pnpm install || pnpm install  # Retry logic
      - npm run build
      - du -sh *

  - name: build_image
    image: plugins/docker:20
    depends_on: [build_project]
    # volumes:
    #   - name: docker-sock
    #     path: /var/run/docker.sock
    settings:
      dockerfile: Dockerfile
      registry: registry.cn-beijing.aliyuncs.com
      repo:  registry.cn-beijing.aliyuncs.com/xxx/cp-business-web
      auto_tag: true
      insecure: true
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password


trigger:
  #  branch:
  #    - main
  ref:
    - refs/tags/*
    - refs/heads/master

volumes:
  - name: go_cache
    host:
      path: /root/.go/cache

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50

2、详解

1、name

在这里插入图片描述
在这里插入图片描述

2、step 编译步骤

第一个 image,image: node:20-slim 这里需要你找到开源的镜像

这里commands一定要加上中国的镜像源

    commands:
      - pwd
      - du -sh *
      - npm config set registry https://registry.npmmirror.com
      - npm install -g pnpm || npm install -g pnpm || npm install -g pnpm  # Retry logic
      - pnpm config set store-dir /drone/src/node_modules/.pnpm-store
      - pnpm install || pnpm install || pnpm install  # Retry logic
      - npm run build
      - du -sh *
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

这里是重要的防墙处理如果不处理 则npm 一安装就报错

3、各种报错如下

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

二、drone 讲解请参考如下:

https://ctraplatform.blog.csdn.net/article/details/130003341

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/秋刀鱼在做梦/article/detail/869323
推荐阅读
相关标签
  

闽ICP备14008679号