1. Mirror acquisition
# Get verdaccio imagedocker pull verdaccio/verdaccio
2. Modify the configuration file
cd /wwwroot/opt/docker/verdaccio/conf vim
The configuration file is as follows, and can be modified according to your needs
# # 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: # /verdaccio/verdaccio/tree//conf # # Read about the best practices # /docs/best # path to a directory with all packages storage: ./storage # path to a directory with plugins to include plugins: ./plugins # /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="/"></script>' # HTML tags injected before ends </head> # metaScripts: # - '<script type="text/javascript" src="/jquery-3.5."></script>' # - '<script type="text/javascript" src="/5.15.5/"></script>' # - '<meta name="robots" content="noindex" />' # HTML tags injected first child at <body/> # bodyBefore: # - '<div >html before webpack scripts</div>' # Public path for template manifest scripts (only manifest) # publicPath: / # /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 # /docs/configuration#uplinks # a list of other known repositories we can talk to uplinks: taobao: url: / npmjs: url: / yarnkg: url: / tencent: url: /npm/ cnpm: url: / npmMirror: url: /registry/ # Learn how to protect your packages # /docs/protect-your-dependencies/ # /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 # /docs/best#remove-proxy-to-increase-security-at-private-packages # /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 versions prior to 8.0.0, which did not have a keep-alive timeout. # WORKAROUND: Through given configuration you can workaround following issue /verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enough. server: keepAliveTimeout: 60 # /docs/configuration#offline-publish # publish: # allow_offline: false # /docs/configuration#url-prefix # url_prefix: /verdaccio/ # VERDACCIO_PUBLIC_URL=''; # url_prefix: '/my_prefix' # // url -> /my_prefix/ # VERDACCIO_PUBLIC_URL=''; # url_prefix: '/' # // url -> / # VERDACCIO_PUBLIC_URL='/first_prefix'; # url_prefix: '/second_prefix' # // url -> /second_prefix/' # /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] # /docs/configuration#user-rate-limit # userRateLimit: # windowMs: 50000 # max: 1000 # /docs/configuration#max-body-size max_body_size: 50mb # /docs/configuration#listen-port listen: - '0.0.0.0:4873' # listen on all addresses (INADDR_ANY) # - :4873 # if you want to use https # - "[::1]:4873" # ipv6 # - unix:/tmp/ # unix socket # The HTTPS configuration is useful if you do not consider use a HTTP Proxy # /docs/configuration#https # https: # key: ./path/ # cert: ./path/ # ca: ./path/ # /docs/configuration#proxy # http_proxy: / # https_proxy: / # /docs/configuration#notifications notify: method: POST headers: [{ "Content-Type": "application/json;charset=utf-8" }] # The webhook sending message endpoint: xxx content: '{ "msgtype": "text","at": { "isAtAll": true }, "text": {"content":"Component release notification: { { name }}{ {#each versions}} v{ {version}}{ {/each}}"}}' middlewares: audit: enabled: true # /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 /verdaccio/verdaccio/blob/master/packages/plugins/ui-theme/src/i18n/ABOUT_TRANSLATIONS.md web: zh-CN
auth: htpasswd: file: ./htpasswd # is the user password file of npm private server max_body_size: 50mb # is the maximum size of the package to be pushed on to the private server listen: - '0.0.0.0:4873' # is the IP and port for listening, and 4873 is the port to be accessed later notify: method: POST headers: [{ "Content-Type": "application/json;charset=utf-8" }] # The webhook address that sends the message after pushing the package. If not, no configuration is required. endpoint: xxx
3. Create container and run
docker run -d --name verdaccio \n -p 4873:4873 \n -v /wwwroot/opt/docker/verdaccio:/verdaccio \n --privileged=true verdaccio/verdaccio
4. Test operation
At this time, verdaccio has been started, and http://ip:4873/ can be accessed
5. The web interface pit that uses intranet penetration
When building a company's private library, the intranet IP is used, but in order to facilitate access outside, the operation will penetrate the intranet IP to obtain an IP that can be accessed by the outside network. However, you cannot use the intranet IP and the external IP to access the web page at the same time. Checking the page request of verdaccio will cache the domain name requested for the first time that day. Assuming that the intranet environment domain name is accessed on the same day, the external environment web page will not be accessible because the request is written to the intranet address. If the external network address is accessed first, the intranet address will jump to the unpacked page.
This is the end of this article about the implementation of Docker deployment of verdaccio to build npm private servers. For more related content on Docker Verdaccio to build Npm, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!