Skip to content

Commit 3f8441c

Browse files
authored
readme: 添加部署说明
1 parent 92a80e0 commit 3f8441c

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,68 @@ URL 参数:`modId`
118118
- QQ: 3531890582
119119
- QQ 群聊: [OpenMCIM](https://qm.qq.com/q/ZSN6ilHEwC)
120120

121+
## 部署
122+
123+
首先你需要在 MongoDB 向 `mcim_backend` 导入 [MCIM Data](https://github.com/mcmod-info-mirror/data) 的数据,或者运行自行 [MCIM Sync](https://github.com/mcmod-info-mirror/mcim-sync) 进行抓取。你可以直接调用它完成 Modrinth 的抓取,但你很可能需要依靠用户请求来收集到 Curseforge 的 Mod,暂无方式可以抓取 Curseforge 的全部 Mod。
124+
125+
然后用 Docker 部署 <https://hub.docker.com/r/z0z0r4/mcim-rust-api>,或者你可以自行构建,将环境变量填在 `.env` 直接运行。
126+
127+
### 🐳 使用 `docker run`
128+
129+
```bash
130+
docker run -d \
131+
--name mcim-rust-api \
132+
--restart always \
133+
--network host \
134+
-e RUST_LOG=INFO \
135+
-e MONGODB_URI="mongodb://user:password@localhost" \
136+
-e REDIS_URL="redis://localhost" \
137+
-e CURSEFORGE_API_URL="https://api.curseforge.com" \
138+
-e MODRINTH_API_URL="https://api.modrinth.com" \
139+
-e CURSEFORGE_API_KEY="CURSEFORGE_API_KEY" \
140+
-e CURSEFORGE_FILE_CDN_URL="https://edge.forgecdn.net" \
141+
-e MODRINTH_FILE_CDN_URL="https://cdn.modrinth.com" \
142+
z0z0r4/mcim-rust-api:latest
143+
```
144+
145+
---
146+
147+
### 📦 使用 `docker-compose`
148+
149+
`docker-compose.yml` 文件:
150+
151+
```yaml
152+
services:
153+
mcim-rust-api:
154+
container_name: mcim-rust-api
155+
image: z0z0r4/mcim-rust-api:latest
156+
restart: always
157+
network_mode: host
158+
environment:
159+
RUST_LOG: INFO
160+
PORT: 8080
161+
MONGODB_URI: "mongodb://user:password@localhost"
162+
REDIS_URL: "redis://localhost"
163+
CURSEFORGE_API_URL: "https://api.curseforge.com"
164+
MODRINTH_API_URL: "https://api.modrinth.com"
165+
CURSEFORGE_API_KEY: "CURSEFORGE_API_KEY"
166+
CURSEFORGE_FILE_CDN_URL: "https://edge.forgecdn.net"
167+
MODRINTH_FILE_CDN_URL: "https://cdn.modrinth.com"
168+
```
169+
170+
## 🛠 环境变量说明
171+
172+
| 变量名 | 说明 |
173+
| ------------------------- | ----------------------- |
174+
| `MONGODB_URI` | MongoDB 数据库连接字符串 |
175+
| `REDIS_URL` | Redis 连接地址 |
176+
| `CURSEFORGE_API_URL` | CurseForge API 根地址 |
177+
| `CURSEFORGE_API_KEY` | CurseForge API Key |
178+
| `CURSEFORGE_FILE_CDN_URL` | CurseForge 文件 CDN 地址 |
179+
| `MODRINTH_FILE_CDN_URL` | Modrinth 文件 CDN 地址 |
180+
181+
> 🔒 请将 `MONGODB_URI`、`REDIS_URL` 与 `CURSEFORGE_API_KEY` 替换为你自己的配置。
182+
121183
### 声明
122184

123185
MCIM 是一个镜像服务平台,旨在为中国大陆用户提供稳定的 Mod 信息镜像服务。为维护 Mod 创作者及源站平台的合法权益,MCIM 制定以下协议及处理方式:

0 commit comments

Comments
 (0)