搭建npm和docker私有仓库
- 0
#讨论区
00条评论
实时对话
loading...
bash
bash
nexus的jvm默认内存比较大,可能起不来,我们可以调小一点
bash
看看有没有启动成功
bash
version: '3'
services:
nexus3:
image: sonatype/nexus3
environment:
- TZ=Asia/Shanghai
- "INSTALL4J_ADD_VM_PARAMS=-Xms128m -Xmx512m -XX:MaxDirectMemorySize=512m -Djava.util.prefs.userRoot=/some-other-dir"
ports:
- '8081:8081'
- '8443:8443'
- '9102:9102'
- '9101:9101'
- '9103:9103'
- '9200:9200'
- '9201:9201'
restart: always
volumes:
- './keystore.jks:/opt/sonatype/nexus/etc/ssl/keystore.jks:ro'
- './keystore.cer:/opt/sonatype/nexus/etc/ssl/keystore.cer:ro'
- './nexus-default.properties:/opt/sonatype/nexus/etc/nexus-default.properties:ro'
- './jetty-https.xml:/opt/sonatype/nexus/etc/jetty/jetty-https.xml:ro'
首先我们进入容器
bash
查看默认密码
bash
docker不使用ssl或者使用自签的ssl每个客户端都需要配置一遍,不然会报错certificate signed by unknown authority
,所以选取免费的商业证书,
.npmrc
文件
_auth
是 username:password 的base64值
registry=http://127.0.0.1:8081/repository/npm-group
_auth=ZGVwbG95ZXI6ZGVwbG95ZXI=
npm cache clean -f
⚠️注意私有包地址是hosted不是group或者proxy
直接使用命令关联仓库发布
bash
在package.json添加配置发布
json
bash
查看安装信息
bash
https://github.com/cnpm/cnpmcore
npm install -g verdaccio
//npm.zzfzzf.com/:_authToken=NpmToken
@zzf:registry=http://npm.zzfzzf.com/
always-auth=true
registry=https://npm.zzfzzf.com/
_auth=base64
docker pull sonatype/nexus3
docker run -d -p 8081:8081 sonatype/nexus3
docker run -d -p 8081:8081 --name nexus -e INSTALL4J_ADD_VM_PARAMS="-Xms2703m -Xmx2703m -XX:MaxDirectMemorySize=2703m -Djava.util.prefs.userRoot=/some-other-dir" --restart=always sonatype/nexus3
curl http://localhost:8081/
docker exec -it container_id bash
cat /nexus-data/admin.password
npm publish --registry=http://localhost:8081/repository/npm-hosted/
{
"publishConfig" : {
"registry" : "http://localhost:8081/repository/npm-hosted/"
}
}
npm publish
npm --loglevel info install react