1. Install the docker
1. Install the docker
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
Copy the code
Docker -v Checks whether the Docker is successfully installed
2. Install the docker – compose
sudo curl -L "Https://github.com/docker/compose/releases/download/1.28.6/docker-compose-$(uname -s) - $(uname -m)" -o /usr/local/bin/docker-compose
Copy the code
Docker-compose -v Checks whether docker-compose is successfully installed
-bash: /usr/local/bin/docker-compose: Permission denied The Permission is insufficient
chmod +x /usr/local/bin/docker-compose
3. Write a docker – compose. Yml
/verdaccio/docker-compose.yml
version: '3.1'
services:
verdaccio:
image: verdaccio/verdaccio
container_name: "verdaccio"
networks:
- node-network
environment:
- VERDACCIO_PORT=4873
ports:
- "4873:4873"
volumes:
- "./storage:/verdaccio/storage"
- "./config:/verdaccio/conf"
- "./plugins:/verdaccio/plugins"
networks:
node-network:
driver: bridge
Copy the code
4. Write. / config/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://verdaccio.org/docs/en/docker#docker-and-custom-port-configuration
#
# Look here for more config file examples:
# https://github.com/verdaccio/verdaccio/tree/master/conf
#
# path to a directory with all packages
storage: /verdaccio/storage/data
# path to a directory with plugins to include
plugins: /verdaccio/plugins
web:
# WebUI is enabled as default, if you want disable it, just uncomment this line
#enable: false
title: Verdaccio
# comment out to disable gravatar support
# gravatar: false
# by default packages are ordercer ascendant (asc|desc)
# sort_packages: asc
# darkMode: true
# translate your registry, api i18n not available yet
# i18n:
# list of the available translations https://github.com/verdaccio/ui/tree/master/i18n/translations
# web: en-US
auth:
htpasswd:
file: /verdaccio/storage/htpasswd
# Maximum amount of users allowed to register, defaults to "+infinity".
# You can set this to -1 to disable registration.
max_users: 1000
# a list of other known repositories we can talk to
uplinks:
npmjs:
url: https://registry.npmjs.org/
packages:
'@ */*': # scoped packages access: $all publish: $authenticated unpublish: $authenticated proxy: 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" 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: npmjs middlewares: audit: enabled: true # log settings logs: - { type: stdout, format: pretty, level: http } #- {type: file, path: verdaccio.log, level: info} #experiments: # # support for npm token command # token: false # # support for the new v1 search endpoint, functional by incomplete read more on ticket 1732 # search: false # This affect the web and api (not developed yet) #i18n: #web: en-USCopy the code
Docker-compose up -d
docker-compose up -d
Open the browser IP address :4873. The page is displayed
6. Add a user
npm adduser –registry your.npm-server.com
Enter the user name and password as prompted and end up with a 500 server error. We run the following command on the server to view the container logs:
docker logs –tail 20 verdaccio
Found: EACCES: permission denied, open ‘/ verdaccio/storage/htpasswd’ turns out to be no permissions. After checking some information, it is learned that the user will write htpasswd file when adding NPM user. Since this file is in the host machine, it is created by root user by default, and the verdaccio container has its own user name, which is called Verdaccio. Therefore, files owned by root cannot be written. Do you want to create a new Verdaccio user on the host? Don’t bother. According to the official document and the last article at the end of this article, the UID and GID in docker container are shared with the host computer without specific name, while the UID and GID used by Verdaccio in the container are 10001 and 65533. So let’s change the htpasswd file permissions on the host:
sudo chown 10001:65533 htpasswd
Then try adding a user and you’ll be done. Similarly, the storage directory is the directory where Verdaccio stores the package data, and it also needs to change the permissions:
sudo chown -R 10001:65533 storage
7. Code push
npm publish –registry your.npm-server
8. Failed to push the NPM package because it was too large
verdaccio Error: 413 content Too Large – the PUT request entity Too Large docker NPM default package size to 10 MB, modify verdaccio/config/config. The yaml
.max_body_size: 100mb
Copy the code