Skip to content

Commit

Permalink
docs: update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhan005 committed Sep 15, 2024
1 parent a400990 commit 8763962
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 95 deletions.
61 changes: 34 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,57 +28,64 @@ NekoBox

![Screenshot](./dev/screenshot.svg)

## Installation
## Deployment

### Prerequisite
### Docker Deployment

1. Create a Configuration File

Create a configuration file `app.ini` based on the template `conf/app.sample.ini`. Adjust the settings as needed by
referring to the comments in the file.

2. Start the Container

```bash
# Pull the latest image
docker pull ghcr.io/nekowheel/nekobox:master

# Start the container (listen on port 80 and mount the configuration file)
docker run -dt --name NekoBox -p 80:80 -v $(pwd)/app.ini:/app/conf/app.ini ghcr.io/nekowheel/nekobox:master
```

### Build from Source

1. Requirements

* [Go](https://golang.org/dl/) (v1.19 or higher)
* [MySQL](https://www.mysql.com/downloads/) (v5.7 or higher)
* [Redis](https://redis.io/download/) (v6.0 or higher)

### Build from source
2. Compile the Source Code

```bash
# Clone the source code
git clone https://github.com/NekoWheel/NekoBox.git

# Enter the project directory
cd NekoBox

go build -o NekoBox
# Build the binary for the current system and architecture
go build -v -ldflags "-w -s -extldflags '-static'" -o NekoBox ./cmd/

# Build the binary for Linux, AMD64 architecture
GOOS=linux GOARCH=amd64 go build -v -ldflags "-w -s -extldflags '-static'" -o NekoBox ./cmd/
```

### Edit the configuration file
3. Edit the Configuration File

Create a configuration file based on the template `conf/app.sample.ini`. Adjust the settings as needed by referring to
the comments in the file.

```bash
cp conf/app.sample.ini conf/app.ini
```

### Run
4. Run

```bash
./NekoBox web
```

## Architecture

NekoBox uses GitHub Actions for continuous integration and deployment.

When a user visit NekoBox, the request will be routed to Cloudflare CDN.

User's profile, questions and answers will be stored in MySQL database.

User's session, CSRF token and email verification token will be stored in Redis temporarily.

The entire request and response chain will be uploaded to Uptrace for debugging purposes. The data will be stored in
Uptrace for 30 days. Administrators can use the `TraceID` provided by users to query the specified request context.

When a user submits a question, the content of the question will be sent to Aliyun text censoring service for review. If the
content does not pass, the question will be rejected.

When a user received a new question, an email will be sent to the user's email address by Aliyun mail service (DM).

In the main page, you can check out the changelogs of NekoBox, and you can visit the sponsor page to support NekoBox at
the bottom of the page. The changelogs and sponsor list are stored in Cloudflare Pages which is deployed separately.

## License

MIT License
59 changes: 32 additions & 27 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,57 +28,62 @@ NekoBox

![Screenshot](./dev/screenshot.svg)

## 安装
## 部署

### 需求
### Docker 部署

1. 创建配置文件

基于配置文件模板 `conf/app.sample.ini` 创建配置文件 `app.ini`,相关配置可参考注释进行调整。

2. 启动容器

```bash
# 拉取最新镜像
docker pull ghcr.io/nekowheel/nekobox:master

# 启动容器(监听 80 端口并挂载配置文件)
docker run -dt --name NekoBox -p 80:80 -v $(pwd)/app.ini:/app/conf/app.ini ghcr.io/nekowheel/nekobox:master
```

### 从源码构建

1. 环境需求

* [Go](https://golang.org/dl/) (v1.19 或更高版本)
* [MySQL](https://www.mysql.com/downloads/) (v5.7 或更高版本)
* [Redis](https://redis.io/download/) (v6.0 或更高版本)

### 从源码编译
2. 编译源码

```bash
# 克隆源码
git clone https://github.com/NekoWheel/NekoBox.git

# 进入项目目录
cd NekoBox

go build -o NekoBox
# 构建当前机器系统与架构的二进制文件
go build -v -ldflags "-w -s -extldflags '-static'" -o NekoBox ./cmd/

# 构建 Linux、AMD64 架构的二进制文件
GOOS=linux GOARCH=amd64 go build -v -ldflags "-w -s -extldflags '-static'" -o NekoBox ./cmd/
```

### 编辑配置文件
3. 编辑配置文件

基于配置文件模板 `conf/app.sample.ini` 创建配置文件,相关配置可参考注释进行调整。

```bash
cp conf/app.sample.ini conf/app.ini
```

### 运行
4. 运行

```bash
./NekoBox web
```

## 架构

NekoBox 使用 GitHub Actions 进行持续集成和部署。

当用户访问 NekoBox 时,请求将会被发送至 Cloudflare CDN。

用户的信息、提问和回答将被存储在 MySQL 数据库中。

用户的会话、CSRF 令牌和电子邮件验证令牌将被暂时存储在 Redis 中。

用户的整个请求和响应链路将被上传到 Uptrace 用于调试。这些数据将被储存 30 天。管理员可以使用用户提供的 `TraceID`
来追踪查询指定的请求。

当用户提交提问时,问题的内容将被发送到阿里云文本审查服务进行审查。
如果内容审查未通过,该提问将被拒绝发送。

当用户收到新的提问时,阿里云邮件服务(DM)会向用户的邮箱发送一封邮件。

你可以在主页查看 NekoBox 的更新日志,也欢迎访问赞助页面来打钱支持 NekoBox。 更新日志和赞助商名单存储在独立部署的
Cloudflare Pages 中。

## 开源协议

MIT License
80 changes: 41 additions & 39 deletions conf/app.sample.ini
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
[app]
production = true
title = "NekoBox"
icp = ""
uptrace_dsn = ""
qiniu_access_key = ""
qiniu_access_secret = ""
aliyun_access_key = ""
aliyun_access_key_secret = ""
production = true # 是否以线上生产模式运行
title = "NekoBox" # 站点名称
icp = "" # ICP 备案号
external_url = "" # 站点访问地址,如 https://box.n3ko.cc/
uptrace_dsn = "" # 可选:接入 Uptrace,填写 DSN
aliyun_access_key = "" # 开启内容安全时,调用阿里云接口的 Access Key
aliyun_access_key_secret = "" # 开启内容安全时,调用阿里云接口的 Access Key Secret

[security]
enable_text_censor = true
enable_text_censor = true # 是否开启内容安全检查(依赖阿里云内容安全服务)

[server]
port = 80
salt = ""
xsrf_key = ""
xsrf_expire = 3600
port = 80 # 服务监听端口
salt = "" # !! 密码盐值,请务必修改为一个随机的值。
xsrf_key = "" # !! XSRF 密钥,请务必修改为一个随机的值。
xsrf_expire = 3600 # XSRF Token 有效期(秒)

[database]
user = ""
password = ""
address = "tcp(127.0.0.1:3306)"
name = ""
user = "" # MySQL 数据库用户名
password = "" # MySQL 数据库密码
address = "tcp(127.0.0.1:3306)" # MySQL 数据库地址
name = "" # MySQL 数据库名称

[pixel]
host = localhost:8088 # NekoBox 线上 Pixel 画板服务后端

[redis]
addr = "127.0.0.1:6379"
password = ""
addr = "127.0.0.1:6379" # Redis 地址
password = "" # Redis 密码

[recaptcha]
domain = "https://www.recaptcha.net"
site_key = ""
server_key = ""
turnstile_style = false
domain = "https://www.recaptcha.net" # reCAPTCHA 验证码 API 域名
site_key = "" # reCAPTCHA 验证码站点密钥
server_key = "" # reCAPTCHA 验证码服务密钥
turnstile_style = false # 兼容使用 Cloudflare Turnstile 验证码

[upload]
default_avatar = ""
default_background = ""
default_avatar = "" # 默认用户头像地址
default_background = "" # 默认用户背景地址

# User avatar and background.
aliyun_endpoint = ""
aliyun_access_id = ""
aliyun_access_secret = ""
aliyun_bucket = ""
aliyun_bucket_cdn_host = ""
aliyun_endpoint = "" # 用户头像、背景资源文件所在的阿里云 OSS Endpoint
aliyun_access_id = "" # 阿里云 OSS Access Key
aliyun_access_secret = "" # 阿里云 OSS Access Key Secret
aliyun_bucket = "" # 阿里云 OSS Bucket 名称
aliyun_bucket_cdn_host = "" # 阿里云对外 CDN 域名

# User uploaded images.
image_endpoint = ""
image_access_id = ""
image_access_secret = ""
image_bucket = ""
image_bucket_cdn_host = ""
image_endpoint = "" # 用户上传的图片所在的阿里云 OSS Endpoint
image_access_id = "" # 阿里云 OSS Access Key
image_access_secret = "" # 阿里云 OSS Access Key Secret
image_bucket = "" # 阿里云 OSS Bucket 名称
image_bucket_cdn_host = "" # 阿里云对外 CDN 域名

[mail]
account = ""
password = ""
port = 465
smtp = ""
account = "" # SMTP 邮箱账号
password = "" # SMTP 邮箱密码
port = 465 # SMTP 端口
smtp = "" # SMTP 服务器地址
2 changes: 0 additions & 2 deletions internal/conf/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ var (
ExternalURL string `ini:"external_url"`
ICP string `ini:"icp"`
UptraceDSN string `ini:"uptrace_dsn"`
QiniuAccessKey string `ini:"qiniu_access_key"`
QiniuAccessSecret string `ini:"qiniu_access_secret"`
AliyunAccessKey string `ini:"aliyun_access_key"`
AliyunAccessKeySecret string `ini:"aliyun_access_key_secret"`
SentryDSN string `ini:"sentry_dsn"`
Expand Down

0 comments on commit 8763962

Please sign in to comment.