npm通过verdaccio搭建私服镜像库

位置:首页>文章>详情   分类: 教程分享   阅读(365)   2024-04-13 13:37:54

npm通过verdaccio搭建私服镜像库,以此提高本地多人协同install速度。verdaccio安装方式选为docker方式。

docker相关知识可以查看往期相关文章:

 

 

首先是配置 docker-compose.yml配置

version: "3.8"

networks:
  vRouter:
    external: false

services:
  verdaccio: 
    image: verdaccio/verdaccio:5.30.3
    container_name: verdaccio
    restart: always
    volumes: 
      - ./conf:/verdaccio/conf
      - ./storage/:/verdaccio/storage
      - ./plugins:/verdaccio/plugins
    ports: 
      - '7749:4873'
    networks:
      vRouter:
        aliases:
          - verdaccio.server

    deploy:
      resources:
        limits:
          memory: 300M

注意:上方配置将verdaccio默认端口4873映射到了主机7749上

上传docker-compose.yml到目录 /opt/docker/verdaccio下,并在该目录下创建conf storage plugins 三个目录,且赋权777解决一些莫名其妙的docker内部权限不足问题。

mkdir -p /opt/docker/verdaccio
cd /opt/docker/verdaccio
mkdir conf storage plugins
chmod 777 -R conf storage plugins

在conf创建verdaccio默认配置文件config.yaml,内容参考如下:

#
# This is the config file used for the docker images.
# It allows all users to do anything, so don't use it on production systems.
#
# Do not configure host and port under `listen` in this file
# as it will be ignored when using docker.
# see https://github.com/verdaccio/verdaccio/blob/master/wiki/docker.md#docker-and-custom-port-configuration
#
# Look here for more config file examples:
# https://github.com/verdaccio/verdaccio/tree/master/packages/config/src/conf
#

# 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 "+inf".
    # You can set this to -1 to disable registration.
    #max_users: 1000
    #[modify by leftso]
    max_users: -1
security:
  api:
    jwt:
      sign:
        expiresIn: 60d
        notBefore: 1
  web:
    sign:
      expiresIn: 7d

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

packages:
  '@jota/*':
    access: $all
    publish: $all

  '@*/*':
    # scoped packages
    access: $all
    publish: $all
    proxy: taobao 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"
    #[modify by leftso]
    access: $anonymous

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

    # 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
log:
  - { type: stdout, format: pretty, level: trace }
  #- {type: file, path: verdaccio.log, level: info}

文档参考官方的,做了几处修改分别标记了#[modify by leftso]

access: $anonymous 由之前的access: $all 修改的,默认的$all表示所有用户,我这里需要匿名访问,不需要用户所以配置了$anonymous

作为镜像完全够了

配置文件也记得改成777

chmod 777 config.yml

返回/opt/docker/verdaccio 目录启动

sudo docker-compose up -d

启动完成后通过主机ip:端口访问

操作示例图-38136812edba481c8bc8b73f6ec1be5c.png

点配置齿轮可以修改默认的语言和查看如何配置仓库,参考:

操作示例图-c452aa3838964e5b8bf229118d794165.png

操作示例图-9dcf4458f35c4558869f766db4924ce5.png

重要提示:由于js文件小巧且npm依赖一般多,所以比较耗费硬盘io资源,建议独立部署镜像应用。或找一个SSD的硬盘部署,防止io过高导致系统boom哟

 

verdaccio的更多私服功能如用户上传自己的库等后续再更...

 

 

地址:https://www.leftso.com/article/2404131124399972.html

相关阅读

npm通过verdaccio搭建私服镜像库,以此提高本地多人协同install速度。verdaccio安装方式选为docker方式。docker相关知识可以查看
npm查看当前配置 npm config get registry设置新的配置 npm config set registry https://*.com/path/​​​​​​​代码段 小部件
npm配置国内镜像源
错误日志参考:npm ERR! code ERESOLVEnpm ERR! ERESOLVE unable to resolve dependency tree
idea maven https私服下载报错解决idea 打开设置菜单,找到setting-&gtl;Build,Excution,Deployment-&gtl;Build Tools&gtl...
在初始化完一个vue项目(基于vue-cli 和webpack)之后,我们可以通过 npm run dev来让这个项目跑起来
MQTT协议 Java入门教程,通过Apache ActiveMQ Artemis搭建MQTT服务器。首先下载Apache ActiveMQ Artemis,目前Apache ActiveMQ ...
1.打开github nodejs源码地址GitHub - nodesource/distributions: NodeSource Node.js Binary Distributions2....
一、maven私服上传自建的jar之项目的pom.xml文件配置 <repositories&gtl;<--私服下载配置--&gtl; <repository&gtl...