base on BMCLAPI@Home # BMCLAPI
BMCLAPI是@bangbang93开发的BMCL的一部分,用于解决国内线路对Forge和Minecraft官方使用的Amazon S3 速度缓慢的问题。BMCLAPI是对外开放的,所有需要Minecraft资源的启动器均可调用。
# OpenBMCLAPI
这个项目的主要目的是辅助bmclapi分发文件
对节点的要求降低了不少
1. 公网可访问(端口映射也可),可以非80
2. 10Mbps以上的上行速度
3. 暂时不接受国外节点了
4. 可以长时间稳定在线
5. 暂不支持IPv6 only(可以双栈)
[Wiki](https://github.com/bangbang93/openbmclapi/wiki)
- 如果你是家庭宽带打算参与,配置信息可以参考 [家宽搭建说明](https://github.com/bangbang93/openbmclapi/wiki/%E5%AE%B6%E5%AE%BD%E6%90%AD%E5%BB%BA%E8%AF%B4%E6%98%8E)
- 如果你是国内服务器打算参与,配置信息可以参考 [国内服务器搭建说明](https://github.com/bangbang93/openbmclapi/wiki/%E5%9B%BD%E5%86%85%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%90%AD%E5%BB%BA%E8%AF%B4%E6%98%8E)
安装
---
### Docker Cli
如果你不熟悉docker,可以参考[Docker部署指北](https://github.com/bangbang93/openbmclapi/wiki/docker%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8C%97)
```bash
docker run -d \
-e CLUSTER_ID=${CLUSTER_ID} \
-e CLUSTER_SECRET=${CLUSTER_SECRET} \
-e CLUSTER_PUBLIC_PORT=${CLUSTER_PORT} \
-e TZ=Asia/Shanghai \
-v /data/openbmclapi:/opt/openbmclapi/cache \
-p ${CLUSTER_PORT}:4000 \
--restart always \
--name openbmclapi \
bangbang93/openbmclapi
```
若无法访问 Docker Hub Registry, 可以使用国内镜像:
```bash
docker pull registry.bangbang93.com/bmclapi/openbmclapi
```
### Docker Compose
请先根据 [设置参数](#设置参数) 中说明的内容创建 `.env` 文件或直接更改 `docker-compose.yml` 文件, 然后运行以下命令:
```bash
docker compose up -d
```
## 配置
| 环境变量 | 必填 | 默认值 | 说明 |
|---------------------|----|--------------|--------------------------------------------------------------------------------------------------------|
| CLUSTER_ID | 是 | - | 集群 ID |
| CLUSTER_SECRET | 是 | - | 集群密钥 |
| CLUSTER_IP | 否 | 自动获取公网出口IP | 用户访问时使用的 IP 或域名 |
| CLUSTER_PORT | 否 | 4000 | 监听端口 |
| CLUSTER_PUBLIC_PORT | 否 | CLUSTER_PORT | 对外端口 |
| CLUSTER_BYOC | 否 | false | 是否使用自定义域名, (BYOC=Bring you own certificate),当使用国内服务器需要备案时, 需要启用这个参数来使用你自己的域名, 并且你需要自己提供ssl termination |
| ENABLE_NGINX | 否 | false | 使用 nginx 提供文件服务 |
| DISABLE_ACCESS_LOG | 否 | false | 禁用访问日志输出 |
| ENABLE_UPNP | 否 | false | 启用 UPNP 端口映射 |
| SSL_KEY | 否 | - | (仅当开启BYOC时) SSL 证书私钥。可以直接粘贴证书内容,也可以填写文件名 |
| SSL_CERT | 否 | - | (仅当开启BYOC时) SSL 证书公钥。可以直接粘贴证书内容,也可以填写文件名 |
如果你在源码中发现了其他环境变量, 那么它们是为了方便开发而存在的, 可能会随时修改, 不要在生产环境中使用
### 安装包
从 [Github Release](https://github.com/bangbang93/openbmclapi/releases) 中选择对应你的系统的最新版本
### 从源码安装
#### 环境
- Node.js 18以上
- Windows/MacOS/Linux, x86/arm均可 (凡是nodejs支持的环境都可以)
#### 设置环境
1. 去 <https://nodejs.org/zh-cn/> 下载LTS版本的nodejs并安装
2. Clone 并安装依赖
```bash
git clone https://github.com/bangbang93/openbmclapi
cd openbmclapi
## 安装依赖
npm ci
## 编译
npm run build
## 运行
node dist/index.js
```
3. 如果你看到了 `CLUSTER_ID is not set` 的报错, 说明一切正常, 该设置参数了
### 设置参数
在项目根目录创建一个文件, 名为 `.env`
写入如下内容
```env
CLUSTER_ID=你的CLUSTER_ID
CLUSTER_SECRET=你的CLUSTER_SECRET
CLUSTER_PORT=对外访问端口
```
CLUSTER_ID 和 CLUSTER_SECRET 请联系我获取
如果配置无误的话, 运行程序, 就会开始拉取文件, 拉取完成后就会开始等待服务器分发请求了
### 同步数据
openbmclapi 会自行同步需要的文件, 但是初次同步可能会速度过慢, 如果您的节点是个全量节点, 可以通过以下命令使用rsync快速同步
以下三台rsync服务器是相同的, 你可以选择任意一台进行同步
- `rsync -rzvP
[email protected]::openbmclapi cache`
- `rsync -avP
[email protected]::bmcl cache`
- `rsync -azvrhP
[email protected]::volume cache`
", Assign "at most 3 tags" to the expected json: {"id":"8212","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"