Easypack Container series: Nexus 3:NPM Private Library

Source: Internet
Author: User
Tags curl docker run


As one of the most popular tools for private library management, Nexus is used in the management of packages and in the private library management scene of Docker mirroring management, but it can also be used in the management of NPM Private library. Why Nexus 3

Here to organize why the use of Nexus 3 for some reasons, in doing selection can make a simple reference.

Project detailed
Why use Nexus 3 http://blog.csdn.net/liumiaocn/article/details/62050525
Docker version

The version of the Docker used is 17.09.0-ce, but is not limited to this version, and other versions are not validated.

[Root@angular ~]# Docker version
Client:
 version:      17.09.0-ce
 API version:  1.32 Go
 version :   go1.8.3
 Git commit:   afdb6d4
 Built:        Tue Sep 22:39:28 2017
 :      os/arch AMD64

Server:
 version:      17.09.0-ce
 API version:  1.32 (minimum Version 1.12) go
 Version :   go1.8.3
 Git commit:   afdb6d4
 Built:        Tue Sep 22:45:38 2017
 :      os/arch AMD64
 experimental:false
[Root@angular ~]#
Download Mirror
[Root@angular ~]# Docker pull Liumiaocn/nexus
Using default tag:latest
latest:pulling from Liumiaocn/nexus
d9aaf4d82f24:pull Complete 
1bf6f9237306:pull complete 2cb68a4c7b1e:pull complete 
: Pull Complete 
ea509a1d48c2:pull complete 
24d48f5e8202:pull complete 
: 3480d50b7ddfb72fe77ce55c7b5ce0a9aa7b6cfa90886a8f8ddc4a2401f1b7c9
status:downloaded newer image for LIUMIAOCN /nexus:latest
[Root@angular ~]#
Start Nexus
Project detailed
Nexus UI 8081
Private repo 8082
Proxy repo 8083
Url http://192.168.163.151:8081/
[Root@angular ~]# Docker run-d-P 8081:8081-p 8082:8082-p 8083:8083--name Nexus Liumiaocn/nexus
Ea85e774529dd6c0daf8833d1e505d4c1f09db00491e87
[Root@angular ~]#
logon
Project detailed
Url http://192.168.163.151:8081/
User name Admin
User password Admin123

After landing
Warehouse Type

The specific warehouse types are mainly divided into three kinds of hosted/proxy/group. The specific meaning is as follows:

Project Detailed Description
Hosted Local storage, providing local private library capabilities
Proxy Provide a type of agent for other warehouses
Group Group type, you can combine multiple warehouses to provide services for one address
Create blob

Create a BLOB to store NPM-related data.

Project Detailed Description
Type File
Name Npm-repo-blob
PATH /nexus-data/blobs/npm-repo-blob


It is recommended that each warehouse in the actual project decide whether or not to create a blob to correspond according to the specific situation, where a demo is used to create the Priavete warehouse using a single blob

Create a hosted warehouse as a private warehouse for managing third party packages in non-NPM communities or for their own development. Details are set out below:

Project Detailed Description
Type NPM (hosted)
Name npm-repo-hosted
Blob Store Npm-repo-blob

The remaining default settings can be
Create a proxy warehouse

Create a proxy warehouse with specific information as follows:

Project Detailed Description
Type NPM (proxy)
Name Npm-repo-proxy
Remote Storage https://registry.npmjs.org
Blob Store Npm-repo-blob

The remaining default settings can be

Note: The Remote Storage here is the address of the registry of NPM that can be connected, need to be guaranteed correctly, and the current machine can be accessed, for example, by using Curl Confirmation:

[Root@angular ~]# Curl https://registry.npmjs.org

Note Here, you can also set the community-related accounts and passwords and other information to further connect. Create a group warehouse

Create a group warehouse with specific information as follows:

Project Detailed Description
Type NPM (Group)
Name Npm-repo-group
Blob Store Npm-repo-blob
Member repositories npm-repo-hosted
Member repositories Npm-repo-proxy

Local NPM Settings Verify with NPM version

[Root@angular ~]# npm-v
5.5.1
[root@angular ~]# node-v-v9.1.0

Specific installation can refer to: http://blog.csdn.net/liumiaocn/article/details/78510679 settings. NPMRC

You can use the following command, or you can modify the. npmrc file directly

[root@angular ~]# npm config set registry http://192.168.163.151:8081/repository/npm-repo-proxy/
[Root@angular ~] #

Confirm. NPMRC

[Root@angular ~]# cat ~/.NPMRC
registry=http://192.168.163.151:8081/repository/npm-repo-proxy/
Confirm

At this point, the Nexus is ready to set up, you can confirm the results. Prior Confirmation

[Root@angular ~]# npm list-g gulp
/usr/local/npm/node/lib └──
(empty)

Install Gulp

Open LogLevel to set it to info, and during the installation you can see NPM http fetch interacting with the newly created proxy warehouse because it downloads the dependent dependencies to the local Nexus's NPM private library.

[Root@angular ~]# npm-loglevel Info install-g Gulp
NPM Info It worked if it ends with OK
npm info using npm@5.5. 1
npm info using node@v9.1.0
...
NPM http fetch get http://192.168.163.151:8081/repository/npm-repo-proxy/gulplog/-/gulplog-1.0.0.tgz 4439ms
...
/usr/local/npm/node/bin/gulp->/usr/local/npm/node/lib/node_modules/gulp/bin/gulp.js ...
NPM Info Lifecycle gulp@3.9.1~postinstall:gulp@3.9.1
+ gulp@3.9.1
added 186 packages in 143.59s
NPM info o K 
[Root@angular ~]# 
results confirmed
[Root@angular ~]# npm list-g gulp
/usr/local/npm/node/lib
└──gulp@3.9.1 

Group Warehouse Confirmation

Gulp 3.9.1 has been visible through the group warehouse
Proxy Warehouse Confirmation

Gulp 3.9.1 has been able to see through the proxy warehouse

Summary

This article briefly describes how to use NEXUS3 to set up and use the NPM private library.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.