Docker部署verdaccio搭建npm私服的實(shí)現(xiàn)
一、鏡像獲取
# 獲取 verdaccio 鏡像 docker pull verdaccio/verdaccio
二、修改配置文件
cd /wwwroot/opt/docker/verdaccio/conf vim config.yaml
config.yaml 配置文件如下,可以根據(jù)自己的需要進(jìn)行修改
#
# This is the default configuration file. It allows all users to do anything,
# please read carefully the documentation and best practices to
# improve security.
#
# Look here for more config file examples:
# https://github.com/verdaccio/verdaccio/tree/5.x/conf
#
# Read about the best practices
# https://verdaccio.org/docs/best
# path to a directory with all packages
storage: ./storage
# path to a directory with plugins to include
plugins: ./plugins
# https://verdaccio.org/docs/webui
web:
title: Verdaccio
# comment out to disable gravatar support
# gravatar: false
# by default packages are ordercer ascendant (asc|desc)
# sort_packages: asc
# convert your UI to the dark side
# darkMode: true
# html_cache: true
# by default all features are displayed
# login: true
# showInfo: true
# showSettings: true
# In combination with darkMode you can force specific theme
# showThemeSwitch: true
# showFooter: true
# showSearch: true
# showRaw: true
# showDownloadTarball: true
# HTML tags injected after manifest <scripts/>
# scriptsBodyAfter:
# - '<script type="text/javascript" src="https://my.company.com/customJS.min.js"></script>'
# HTML tags injected before ends </head>
# metaScripts:
# - '<script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>'
# - '<script type="text/javascript" src="https://browser.sentry-cdn.com/5.15.5/bundle.min.js"></script>'
# - '<meta name="robots" content="noindex" />'
# HTML tags injected first child at <body/>
# bodyBefore:
# - '<div id="myId">html before webpack scripts</div>'
# Public path for template manifest scripts (only manifest)
# publicPath: http://somedomain.org/
# https://verdaccio.org/docs/configuration#authentication
auth:
htpasswd:
file: ./htpasswd
# Maximum amount of users allowed to register, defaults to "+inf".
# You can set this to -1 to disable registration.
# max_users: 1000
# https://verdaccio.org/docs/configuration#uplinks
# a list of other known repositories we can talk to
uplinks:
taobao:
url: https://registry.npm.taobao.org/
npmjs:
url: https://registry.npmjs.org/
yarnkg:
url: https://registry.yarnpkg.com/
tencent:
url: https://mirrors.cloud.tencent.com/npm/
cnpm:
url: https://r.cnpmjs.org/
npmMirror:
url: https://skimdb.npmjs.com/registry/
# Learn how to protect your packages
# https://verdaccio.org/docs/protect-your-dependencies/
# https://verdaccio.org/docs/configuration#packages
packages:
'@*/*':
# scoped packages
access: $all
publish: $authenticated
unpublish: $authenticated
proxy: taobao
'**':
# 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/publish packages
# (anyone can register by default, remember?)
publish: $authenticated
unpublish: $authenticated
# if package is not available locally, proxy requests to 'npmjs' registry
proxy: taobao
# To improve your security configuration and avoid dependency confusion
# consider removing the proxy property for private packages
# https://verdaccio.org/docs/best#remove-proxy-to-increase-security-at-private-packages
# https://verdaccio.org/docs/configuration#server
# You can specify HTTP/1.1 server keep alive timeout in seconds for incoming connections.
# A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout.
# WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enough.
server:
keepAliveTimeout: 60
# https://verdaccio.org/docs/configuration#offline-publish
# publish:
# allow_offline: false
# https://verdaccio.org/docs/configuration#url-prefix
# url_prefix: /verdaccio/
# VERDACCIO_PUBLIC_URL='https://somedomain.org';
# url_prefix: '/my_prefix'
# // url -> https://somedomain.org/my_prefix/
# VERDACCIO_PUBLIC_URL='https://somedomain.org';
# url_prefix: '/'
# // url -> https://somedomain.org/
# VERDACCIO_PUBLIC_URL='https://somedomain.org/first_prefix';
# url_prefix: '/second_prefix'
# // url -> https://somedomain.org/second_prefix/'
# https://verdaccio.org/docs/configuration#security
# security:
# api:
# legacy: true
# jwt:
# sign:
# expiresIn: 29d
# verify:
# someProp: [value]
# web:
# sign:
# expiresIn: 1h # 1 hour by default
# verify:
# someProp: [value]
# https://verdaccio.org/docs/configuration#user-rate-limit
# userRateLimit:
# windowMs: 50000
# max: 1000
# https://verdaccio.org/docs/configuration#max-body-size
max_body_size: 50mb
# https://verdaccio.org/docs/configuration#listen-port
listen:
- '0.0.0.0:4873' # listen on all addresses (INADDR_ANY)
# - https://example.org:4873 # if you want to use https
# - "[::1]:4873" # ipv6
# - unix:/tmp/verdaccio.sock # unix socket
# The HTTPS configuration is useful if you do not consider use a HTTP Proxy
# https://verdaccio.org/docs/configuration#https
# https:
# key: ./path/verdaccio-key.pem
# cert: ./path/verdaccio-cert.pem
# ca: ./path/verdaccio-csr.pem
# https://verdaccio.org/docs/configuration#proxy
# http_proxy: http://something.local/
# https_proxy: https://something.local/
# https://verdaccio.org/docs/configuration#notifications
notify:
method: POST
headers: [{ "Content-Type": "application/json;charset=utf-8" }]
# 發(fā)送消息的webhook
endpoint: xxx
content: '{ "msgtype": "text","at": { "isAtAll": true }, "text": {"content":"組件發(fā)版通知: {
{ name }}{
{#each versions}} v{
{version}}{
{/each}}"}}'
middlewares:
audit:
enabled: true
# https://verdaccio.org/docs/logger
# log settings
logs: { type: stdout, format: pretty, level: http }
#experiments:
# # support for npm token command
# token: false
# # disable writing body size to logs, read more on ticket 1912
# bytesin_off: false
# # enable tarball URL redirect for hosting tarball with a different server, the tarball_url_redirect can be a template string
# tarball_url_redirect: 'http://175.42.30.161:46803/verdaccio/${packageName}/${filename}'
# tarball_url_redirect: 'http://175.42.30.161:46803/${packageName}/${filename}'
# # the tarball_url_redirect can be a function, takes packageName and filename and returns the url, when working with a js configuration file
# tarball_url_redirect(packageName, filename) {
# const signedUrl = // generate a signed url
# return signedUrl;
# }
# translate your registry, api i18n not available yet
i18n:
# list of the available translations https://github.com/verdaccio/verdaccio/blob/master/packages/plugins/ui-theme/src/i18n/ABOUT_TRANSLATIONS.md
web: zh-CN
auth:
htpasswd:
file: ./htpasswd # 是 npm 私服的用戶密碼文件
max_body_size: 50mb # 是推上私服的包的最大大小
listen:
- '0.0.0.0:4873' # 是監(jiān)聽的ip和端口,4873 就是后面訪問的端口
notify:
method: POST
headers: [{ "Content-Type": "application/json;charset=utf-8" }]
# 推包后發(fā)送消息的 webhook 地址,如沒有則不用配置
endpoint: xxx三、創(chuàng)建容器并運(yùn)行
docker run -d --name verdaccio \n -p 4873:4873 \n -v /wwwroot/opt/docker/verdaccio:/verdaccio \n --privileged=true verdaccio/verdaccio
四、測試運(yùn)行
此時(shí),verdaccio已經(jīng)啟動(dòng),http://ip:4873/ 已經(jīng)可以訪問
五、使用內(nèi)網(wǎng)穿透 的 web界面坑
在搭建公司私有庫時(shí),使用的內(nèi)網(wǎng)ip,但是為了在外面方便訪問,運(yùn)營將內(nèi)網(wǎng)ip穿透得到一個(gè)外網(wǎng)可以訪問的ip。但是不能使用內(nèi)網(wǎng)ip和外網(wǎng)ip同時(shí)訪問web頁面。查看verdaccio的頁面請(qǐng)求發(fā)現(xiàn)會(huì)將當(dāng)天第一次請(qǐng)求的域名緩存起來。假設(shè)當(dāng)天先訪問內(nèi)網(wǎng)環(huán)境域名,則外網(wǎng)環(huán)境web頁面將無法訪問,因?yàn)檎?qǐng)求被寫死成內(nèi)網(wǎng)地址,如果先訪問外網(wǎng)地址,則內(nèi)網(wǎng)地址跳轉(zhuǎn)到無包頁面。
到此這篇關(guān)于Docker部署verdaccio搭建npm私服的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Docker Verdaccio搭建Npm內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
如何通過Docker容器創(chuàng)建一個(gè)Web服務(wù)器
這篇文章主要介紹了如何通過Docker容器創(chuàng)建一個(gè)Web服務(wù)器的相關(guān)資料,并對(duì)Nginx進(jìn)行基本配置和測試,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2025-03-03
docker和docker-compose離線安裝實(shí)踐
文章介紹了如何在離線環(huán)境中安裝Docker和Docker Compose,包括下載、解壓、移動(dòng)文件、啟動(dòng)服務(wù)和驗(yàn)證步驟2025-12-12
基于Docker的MongoDB實(shí)現(xiàn)授權(quán)訪問的方法
這篇文章主要介紹了基于Docker的MongoDB實(shí)現(xiàn)授權(quán)訪問的方法,需要的朋友可以參考下2017-03-03
詳解Docker創(chuàng)建支持ssh服務(wù)的容器和鏡像
本篇文章主要介紹了詳解Docker創(chuàng)建支持ssh服務(wù)的容器和鏡像,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-05
docker網(wǎng)絡(luò)及部署集群和打包鏡像問題
這篇文章主要介紹了docker網(wǎng)絡(luò)及部署集群和打包鏡像問題,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-08-08
六種Docker目錄掛載類型及注意事項(xiàng)總結(jié)
這篇文章主要介紹了六種Docker目錄掛載方式,包括數(shù)據(jù)卷掛載、綁定掛載、臨時(shí)文件系統(tǒng)掛載、命名卷掛載、匿名卷掛載和卷驅(qū)動(dòng)掛載,并詳細(xì)說明了每種掛載方式的定義、舉例和注意事項(xiàng),需要的朋友可以參考下2025-03-03
物理機(jī)與啟動(dòng)的Docker容器間的目錄映射方式
這篇文章主要介紹了物理機(jī)與啟動(dòng)的Docker容器間的目錄映射方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-11-11
docker搭建odoo16開發(fā)環(huán)境的實(shí)現(xiàn)
Odoo是全球流行的開源企業(yè)管理套件,本文主要介紹了docker搭建odoo16開發(fā)環(huán)境的實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的可以了解一下2024-04-04

