Build a private NPM library with Verdaccio in Docker

Pull the mirror

  1. performdocker pull verdaccio/verdaccioCommand to pull the latest Verdaccio image in docker

Obtaining configuration files

  1. Run mkdir -p ~/docker/demo to create a docker folder in the root directory. The demo sub-folder is used to pull the Verdaccio project

  2. Run CD ~/docker/demo to go to the demo folder.

Follow the git clone https://github.com/verdaccio/verdaccio orders, pull verdaccio project

  1. performcd verdaccioCommand to enter the project folder,

Git checkout -b 5.x origin/5.x

  1. performcd docker-examplesGo to the docker-examples folder

Run the mv docker-local-storage-volume ~/docker/verdaccio command to move the configuration files under the docker-local-storage-volume folder to the newly created verdaccio folder under the docker

  1. performchown -R 10001:65533 ~/docker/verdaccioSet file permissions. Users in the Verdaccio container in docker environment are not current system users

Boot image

  1. performdocker run --name verdaccio -itd -v ~/docker/verdaccio/conf:/verdaccio/conf -v ~/docker/verdaccio/storage:/verdaccio/storage -p 4873:4873 verdaccio/verdaccioCommand to start the image,

At this time through the docker ps – you can see a container has been started, access to the port 4873 can see warehouse is ready (my own dockerIP is http://192.168.99.100:4873/ for example below)

Publish a package

  1. Those with NRM can passNRM add Warehouse life Warehouse addressAdd a source, such asNRM add verdaccio http://192.168.99.100:4873/.

No NPM set registry http://192.168.99.100:4873/, is every switch to lose url too much trouble

  1. Run NPM adduser, enter user name, password and email address as prompted to add a user, you can also go to the configuration file docker\verdaccio\conf\htpasswd to manually add the user

  2. Run NPM login to login

  3. Perform NPM publish under the package directory to publish

  4. NPM unpublish package name –force

An error

  1. If you havedocker verdaccio one of the uplinks is down, refuse to publishAn error,

You need to modify the configuration file docker\verdaccio\conf\config.yaml and add it to the end of the file

## Special packages publish configurations
publish:
## This will allow the publisher to publish packages even if any uplink is down.
  allow_offline: true
Copy the code