0%

使用verdaccio搭建npmjs服务

verdaccio: A lightweight private npm proxy registry.

Quick Start

直接使用verdaccio/verdaccio镜像启动服务:

1
docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio

或者使用docker-compose进行部署:

1
2
3
4
5
6
7
8
version: '3'
services:
verdaccio:
image: verdaccio/verdaccio
container_name: verdaccio
restart: always
ports:
- 4873:4873

Usage

1
npm install --registry http://localhost:4783/

Deploy with S3

使用S3需要用到verdaccio-s3-storage插件,我们可以基于verdaccio/verdaccio镜像进行修改。

Dockerfile

1
2
3
4
5
6
7
8
9
10
11
FROM verdaccio/verdaccio

USER root
RUN npm install --production \
&& npm install verdaccio-s3-storage
COPY ./conf/config.yaml ./conf/config.yaml

USER 10001

EXPOSE 4873
CMD ["/opt/verdaccio/bin/verdaccio", "--config", "/verdaccio/conf/config.yaml", "--listen", "http://0.0.0.0:4873"]

conf/config.yaml

1
2
3
4
5
6
store:
aws-s3-storage:
bucket: your-bucket-name
s3ForcePathStyle: false
accessKeyId: *
secretAccessKey: ***

docker-compose.yaml

1
2
3
4
5
6
7
8
9

version: '3'
services:
verdaccio:
build: .
container_name: verdaccio
restart: always
ports:
- 4873:4873