Skip to content
This repository has been archived by the owner on Nov 2, 2024. It is now read-only.

Commit

Permalink
add: docker extra config (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhang2003 authored Sep 9, 2024
1 parent 7b0ebb9 commit 3eb2443
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 9 deletions.
6 changes: 6 additions & 0 deletions pages/docs/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ import { EnvVariableConfig } from '@components/EnvVariableConfig'

### 启动 Core

<Callout type="warning" emoji="⚠️">
如果你的服务器在国内,无法拉取镜像或拉取速度过慢可自行使用代理或在 `docker-compose.yml` 里的 image 前添加镜像域名,比如 `docker.1panel.top/innei/mx-server:latest`

镜像域名可参考 [国内 Docker 服务状态 & 镜像加速监控](https://status.1panel.top/status/docker)
</Callout>

```bash
docker compose up -d
```
Expand Down
54 changes: 52 additions & 2 deletions pages/docs/extra.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,33 @@ server {
- `redis_host` Redis 服务地址,域名、IP 都可以
- `redis_port` Redis 服务端口
- `redis_password` Redis 服务密码
- `disable_cache` 是否禁用缓存,默认不启用

在默认情况下,我们认为这样已经足够了。

### 对于 Docker 部署

和编辑其他环境变量一样,在 `service.app``environment` 部分添加你需要传入的值,如下所示:

```yml {9-10}
services:
app:
container_name: mx-server
image: innei/mx-server:latest
environment:
- TZ=Asia/Shanghai
- NODE_ENV=production
- DB_HOST=mongo
- REDIS_HOST=远端地址
- REDIS_PASSWORD=redis?passwd
- ALLOWED_ORIGINS=localhost
- JWT_SECRET=YOUR_SUPER_SECURED_JWT_SECRET_STRING
volumes:
- ./data/mx-space:/root/.mx-space
```
修改完成后 `docker compose up -d` 重启服务即可。

### 对于进阶部署

针对这种部署方式,我们可以修改 `ecosystem.config.js` 在 12 行,也就是 `script` 这一项,添加你需要传入的值,如下所示:
Expand Down Expand Up @@ -247,18 +271,44 @@ pnpm prod:pm2

如果你需要使用来自 (远端 / 非容器) 的 MongoDB 服务,你可以通过使用 `argv` 来动态传入对应的配置项。

支持传入如下值:
支持传入如下值:(除 `collection_name` 外其余变量名在 Docker 中变量均为对应大写)

- `collection_name` 数据库集合名字
- `collection_name` 数据库集合名字(Docker 对应变量为 `DB_COLLECTION_NAME`
- `db_host` MongoDB 服务地址,域名、IP 都可以
- `db_port` MongoDB 服务端口
- `db_user` MongoDB 服务用户名
- `db_password` MongoDB 服务密码
- `db_connection_string` MongoDB 数据库连接地址(以 `mongodb://` 开头的一串内容),此配置项优先级大于上述五项
- `db_options` MongoDB 数据库连接选项

<Callout type="warning" emoji="⚠️">
如果你需要使用密码登录,你不仅仅需要传入 password,还需要传入 user,建议你对数据库集合划分好用户权限
</Callout>

### 对于 Docker 部署

和编辑其他环境变量一样,在 `services.app``environment` 部分添加你需要传入的值,如下所示:

```yml {8-10}
services:
app:
container_name: mx-server
image: innei/mx-server:latest
environment:
- TZ=Asia/Shanghai
- NODE_ENV=production
- DB_HOST=远端地址
- DB_USER=mongodb-test
- DB_PASSWORD=db?passwd
- REDIS_HOST=redis
- ALLOWED_ORIGINS=localhost
- JWT_SECRET=YOUR_SUPER_SECURED_JWT_SECRET_STRING
volumes:
- ./data/mx-space:/root/.mx-space
```
修改完成后 `docker compose up -d` 重启服务即可。

### 对于进阶部署

和 Redis 一样,我们可以修改 `ecosystem.config.js` 在 12 行,也就是 `script` 这一项,添加你需要传入的值,如下所示:
Expand Down
29 changes: 24 additions & 5 deletions pages/themes/shiro/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import { ToGitHub } from '@components/ToGitHub'
- (选择 Vercel 部署)已注册 [Vercel](https://vercel.com/)[GitHub](https://github.com/) 账号

<Callout type="warning">
自 Core v7 起,已抛弃 Clerk,取而待之的是 GitHub 和 Google 的 OAuth 2.0
配置请参考[OAuth 2.0](/usage/oauth)
自 Core v7 起,已抛弃 Clerk,取而代之的是 GitHub 和 Google 的 OAuth 2.0
配置步骤请参考[OAuth 2.0](/usage/oauth)

~~请注意,Shiro 主题的部署教程与初版有所不同,如果你已经部署过 Shiro
主题,请重新阅读本文档(尤其是填入配置文件环节,配置有所变化),并阅读
Expand All @@ -47,16 +47,31 @@ import { ToGitHub } from '@components/ToGitHub'
import { Steps } from 'nextra/components'
import Video from '@components/Video'

export function FAQBox({ title, children }) {
return (
<details
className="last-of-type:mb-0 rounded-lg bg-neutral-50 dark:bg-neutral-800 p-2 mt-4"
>
<summary>
<strong className="text-lg">{title}</strong>
</summary>
<div className="nx-p-2">{children}</div>
</details>
)
}

<Steps>

### 打开 Clerk 创建项目 (已弃用)
<FAQBox title="打开 Clerk 创建项目(已弃用)">

打开 [Clerk 仪表盘](https://dashboard.clerk.com/) 点击 Add application 按钮,填入你的博客名称,并配置信息,点击 Create application 按钮,即可完成配置。

> 请你务必记住你的 Clerk 页面的公钥和私钥,稍后将会用到。
<Video src="https://pan.vinua.cn/f/Mv1Ty/clerk_create_project.mp4" />

</FAQBox>

### 设置主题配置

进入 Mix Space 后台,进入「配置与云函数」页面,点击右上角的新增按钮,在编辑页面中,填入以下设置:
Expand Down Expand Up @@ -314,7 +329,7 @@ import { EnvVariableConfig } from '@components/EnvVariableConfig'

参见 [README 相关部分](https://github.com/Innei/Shiro/blob/main/README.md#whale-运行) 完成对应操作,随后配置[反向代理](/docs/extra#反向代理)

## Clerk 登录与 Mix Space 后端绑定(已过时)
<FAQBox title="Clerk 登录与 Mix Space 后端绑定(已过时)">

如果你遇到在 Shiro 登录之后,无法评论遇到 "和主人重名" 的报错,是因为 Clerk 的用户名和 Mix Space 后端的用户名重复了,你需要绑定本系统和 Clerk 的用户。让某个 Clerk 用户具有管理员权限。

Expand All @@ -340,16 +355,20 @@ Key:

Refer: https://github.com/Innei/Shiro/issues/137

</FAQBox>

## 完成!

至此,你已完成了 Shiro 主题的部署,你可以访问你的博客了。

## 移除 Edge Config
<FAQBox title="移除 Edge Config(已过时)">

在后续的 Shiro 更新中,Edge Config 将不再被使用。你可能需要移除 Edge Config,以防止不必要的资源使用。

进入 Vercel 部署此项目的仪表盘,点击上方的 Storage,进入设置页面,点击左侧的 Projects,将链接的项目取消链接,接着点击左侧的 Settings,点击右侧的 Delete Edge Config 按钮,即可完成删除。

</FAQBox>

## 更新

### Vercel 托管
Expand Down
4 changes: 2 additions & 2 deletions pages/usage/oauth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import { Steps } from 'nextra/components';
参考以下两篇:

- [在 GitHub 新建 OAuth 应用](https://docs.github.com/zh/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app)
- [在 Google Cloud 新建 OAuth 应用](https://developers.google.com/identity/protocols/oauth2/web-server?hl=zh-cn#creatingcred)
- [在 Google Cloud Console 新建 OAuth 应用](https://developers.google.com/identity/protocols/oauth2/web-server?hl=zh-cn#creatingcred)

对于 GitHub,`Homepage URL` 填写前端地址,`Authorization callback URL` 根据后台提示复制粘贴。

对于 Google,`已获授权的 JavaScript 来源` 填写前端地址,`已获授权的重定向 URI` 根据后台提示复制粘贴。
对于 Google,你可能需要先配置好 OAuth 权限请求页面,其中已获授权的网域填写根域名,API 范围选择非敏感范围的三项。OAuth 应用中 `已获授权的 JavaScript 来源` 填写前端地址,`已获授权的重定向 URI` 根据后台提示复制粘贴。

完成后会获取 Client ID 和 Client Secret,将他们复制下来备用。

Expand Down

0 comments on commit 3eb2443

Please sign in to comment.