记录一下如何使用 Docker 和 verdaccio 部署 NPM 私服。
docker-compose.yml
1 2 3 4 5 6 7 8 9 10 11 12 13
| version: '3.4' services: verdaccio: image: verdaccio/verdaccio:5.1 container_name: 'my_npm' environment: - VERDACCIO_PORT=4873 ports: - '80:4873' volumes: - './storage:/verdaccio/storage' - './config:/verdaccio/conf' - './plugins:/verdaccio/plugins'
|
使用 docker-compose up -d
创建容器。稍候打开 http://localhose:80 即可访问,
修改配置
修改 ./config/config.yaml
文件
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
| storage: /verdaccio/storage auth: htpasswd: file: /verdaccio/conf/htpasswd max_users: -1 uplinks: npmjs: url: https://registry.npm.taobao.org/ packages: '@company/*': access: $authenticated publish: $authenticated unpublish: $authenticated proxy: npmjs '@wuxh/*': access: $all publish: $authenticated unpublish: $authenticated proxy: npmjs '**': access: $all publish: $authenticated unpublish: $authenticated proxy: npmjs logs: - { type: stdout, format: pretty, level: http } web: enable: true title: Wuxh-npm i18n: web: zh-CN publish: allow_offline: false
|
参考文档