NPM私有仓库搭建

一、NPM私有仓库搭建的意义

安全性(布署在内网,资产安全性高);
复用性,开发效率,版本管理(立足之根本);
提升下载速度;
公司技术输出沉淀积累形成资产化;

二、 Docker部署verdaccio

安装verdaccio与数据持久化

docker pull verdaccio/verdaccio
mkdir -p /opt/docker/verdaccio/conf 存放#config.yaml与htpasswd
mkdir -p /opt/docker/verdaccio/storage #存放包文件
chown -R 10001:65533 /opt/docker/verdaccio/ #给容器添加物理目录读写权限

写入配置文件config.yaml

# path to a directory with all packages
storage: /verdaccio/storage

auth:
  htpasswd:
    file: /verdaccio/conf/htpasswd
    # Maximum amount of users allowed to register, defaults to "+infinity".
    # You can set this to -1 to disable registration.
    #max_users: 1000

# a list of other known repositories we can talk to
uplinks:
  npmjs:
    url: https://registry.npm.taobao.org/

packages:
  '@*/*':
    # scoped packages
    access: $all
    publish: $authenticated
    proxy: npmjs

  '**':
    # allow all users (including non-authenticated users) to read and
    # publish all packages
    #
    # you can specify usernames/groupnames (depending on your auth plugin)
    # and three keywords: "$all", "$anonymous", "$authenticated"
    access: $all

    # allow all known users to publish packages
    # (anyone can register by default, remember?)
    publish: $authenticated

    # if package is not available locally, proxy requests to 'npmjs' registry
    proxy: npmjs

# To use `npm audit` uncomment the following section
middlewares:
  audit:
    enabled: true

# log settings
logs:
  - {type: stdout, format: pretty, level: http}
  #- {type: file, path: verdaccio.log, level: info}

启动容器

docker run -it --name verdaccio -p 4873:4873 -v /opt/docker/verdaccio/conf:/verdaccio/conf -v /opt/docker/verdaccio/storage:/verdaccio/storage verdaccio/verdaccio

后台启动-it改为-d

上一篇:go语言操作kafka


下一篇:Golang中使用kafka