Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

caser993/unpkg

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

731 Commits
731 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UNPKG (fork)

简体中文 | English

UNPKG is a fast, global content delivery network for everything on npm.

此fork的目标是:

  • 使自托管 Unpkg 变得更容易。
  • 保持上游兼容。
  • 使依赖项保持最新。
  • 不进行任何功能更改或添加新功能。
  • 新增Dockerfile镜像配置。
  • 新增docker-compose.yaml配置(未实测)。
  • 配置dockerrun-ucdn.sh启动脚本。

开发

准备:

git clone https://github.com/caser993/unpkg.git
cd unpkg
pnpm i
cp .env.sample .env.local # and edit the env.local config for local development

dev:

pnpm watch
pnpm serve

构建和部署

cp .env.sample .env.prod # and edit the env.prod config for production
set NODE_ENV=production # or staging
pnpm build
pnpm pack

将生成一个类似“unpkg-.tgz”的文件。 使用 pm2 将其部署到您的服务器中:

tar zxvf unpkg-<version>.tgz
cd package
# npm i --omit dev
pnpm i -P
pm2 -n unpkg start.js

Docker部署

使用docker部署的话,上述构建部署可忽略,直接使用docker方式部署(更推荐) docker image制作

docker build . -t ebear/unpkg

docker image发布

# 内部私有docker registry
docker tag ebear/unpkg ${私有docker仓库目录}/unpkg:latest
docker push ${私有docker仓库目录}/unpkg:latest

docker image使用

# 拉取镜像
docker pull ${私有docker仓库目录}/unpkg:latest

docker 启动配置 启动可直接修改run-ucdn.sh进行快速docker启动或者,或者自行编写启动脚本

方式一:

# 直接修改使用已配置脚本修改启动unpkg方式
vim  run-ucdn.sh
#  -p 3888:8080 \
# -e NODE_ENV=production \
# -e NPM_REGISTRY_URL=https://registry.npmjs.org \
# -e ORIGIN=http://127.0.0.1:4873 \
# ${私有docker仓库目录}/unpkg:latest
source run-ucdn.sh

方式二:

docker run -d -it --name ucdn --restart=always \
  -p 3888:8080 \
  -e NODE_ENV=production \
  -e NPM_REGISTRY_URL=https://registry.npmjs.org \
  -e ORIGIN=http://127.0.0.1:4873 \
  harbor.***.com/base_image/unpkg:latest
  • 默认端口:容器8080,宿主机3888(根据自己实际情况调整)
  • 默认公网NPM地址:NPM_REGISTRY_URL=https://registry.npmjs.org
  • 默认私有NPM地址:ORIGIN=http://http://127.0.0.1:4873(根据自己实际私有库调整)

感谢

此方案非原创,在此感谢renxia的修改升级依赖的支持,本人仅对docker部署部分做了调整新增和一些依赖锁定;源仓库unpkg

About

About The CDN for everything on npm(Privatization Program)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.