Skip to content

Commit

Permalink
Merge pull request #132 from decert-me/chore/README
Browse files Browse the repository at this point in the history
Chore 完善 README 文档
  • Loading branch information
0xdwong authored Mar 28, 2024
2 parents 040361c + 693b14e commit 774a0cc
Show file tree
Hide file tree
Showing 8 changed files with 438 additions and 48 deletions.
52 changes: 38 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,85 @@
```bash
git clone https://github.com/decert-me/backend-go.git
```
## 运行环境

```shell
- Golang >= v1.19 && < v1.21
- Redis
- PostgreSQL
- Docker
```

## 环境配置
1、安装 Docker
脚本一键安装: `sudo curl -sSL https://get.daocloud.io/docker | sh`

详细步骤参照: https://docs.docker.com/install/
## 编译

```bash
# 主程序
go build -o bin/app/decert-app internal/app/cmd/main.go

# 定时处理程序
# 定时任务程序
go build -o bin/job/decert-job internal/job/cmd/main.go

# 授权登录程序
go build -o bin/auth/decert-auth internal/auth/cmd/main.go

# 判题程序
go build -o bin/judge/decert-judge internal/judge/cmd/main.go
```

## 配置

查看各个项目配置说明:
- [主程序配置说明](./internal/app/README.md)
- [定时任务程序配置说明](./internal/job/README.md)
- [授权登录程序配置说明](./internal/auth/README.md)
- [判题程序配置说明](./internal/judge/README.md)


```bash
# 主程序配置
cp ./internal/app/cmd/config.demo.yaml ./bin/app/config.yaml
vi ./bin/app/config.yaml

cp ./internal/app/cmd/locale.json ./bin/app/locale.json
# 定时处理程序配置
# 定时任务程序配置
cp ./internal/job/cmd/config.demo.yaml ./bin/job/config.yaml
vi ./bin/job/config.yaml

# 授权登录程序
cp ./internal/auth/cmd/config.demo.yaml ./bin/auth/config.yaml
vi ./bin/auth/config.yaml

# 判题程序配置
cp ./internal/judge/cmd/config.demo.yaml ./bin/judge/config.yaml
vi ./bin/judge/config.yaml
```
## 运行判题 Docker

## Docker 构建判题镜像

```shell
sudo docker build -t judge:1.0 -f internal/judge/Dockerfile .
```

## 运行

```bash
# 主程序
cd bin/app
./decert-app

# 定时处理程序
# 定时任务程序
cd bin/job
./decert-job

# 授权登录程序
cd bin/auth
./decert-auth

# 判题程序
cd bin/judge
./decert-judge
```



## 测试
```bash
go test ./internal/app/service
go test ./internal/job/service
go test ./pkg/...
```
66 changes: 56 additions & 10 deletions internal/app/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# App

后端程序

## 安装

```bash
git clone https://github.com/decert-me/backend-go.git```]
git clone https://github.com/decert-me/backend-go.git
```

## 编译
Expand All @@ -24,7 +26,7 @@ vi ./bin/app/config.yaml

配置项:

```
```yaml
# system configuration
system:
env: develop
Expand All @@ -34,8 +36,11 @@ system:
```
env:运行环境,可选值为 develop、test、production
addr:运行端口
i18n:国际化配置文件
website:前端网站index.html文件路径,用于代理meta标签
### 数据库配置
Expand All @@ -60,17 +65,29 @@ pgsql:
```
path:数据库地址
port:数据库端口
config:数据库配置
db-name:数据库名称
username:数据库用户名
password:数据库密码
auto-migrate:是否自动迁移数据库
prefix:数据库表前缀
slow-threshold:慢查询阈值,单位毫秒
max-idle-conns:最大空闲连接数
max-open-conns:最大连接数
log-mode:日志级别
log-zap:是否使用zap日志库
Expand All @@ -87,8 +104,11 @@ redis:
```
db:Redis数据库
addr:Redis地址和端口
password:密码
prefix:前缀
### 日志级别配置
Expand All @@ -109,13 +129,21 @@ log:
```
level:日志级别 debug、info、warn、error、dpanic、panic、fatal
save:是否保存日志
format:日志格式
log-in-console:是否在控制台输出日志
prefix:日志前缀
director:日志保存路径
show-line:是否显示行号
encode-level:日志编码级别
stacktrace-key:堆栈信息
### JWT 配置
Expand All @@ -131,7 +159,9 @@ auth:
```
signing-key:签名密钥
expires-time:过期时间,单位秒
issuer:签发人
### 文件上传配置
Expand All @@ -146,6 +176,7 @@ local:
```
path:本地文件保存路径
ipfs:IPFS文件保存路径
### 区块链配置
Expand All @@ -162,8 +193,11 @@ blockchain:
```
ens-rpc:ENS查找RPC地址
sign-private-key:签名私钥
signature:签名内容
signature-exp:签名过期时间,单位秒
### 合约配置
Expand All @@ -179,7 +213,9 @@ contract:
```
badge:badge合约地址
quest:quest合约地址
quest-minter:quest-minter合约地址
### 挑战信息配置
Expand All @@ -206,6 +242,7 @@ ipfs:
```
api:IPFS节点地址
upload-api:IPFS上传API地址
### 代码运行配置
Expand All @@ -220,8 +257,9 @@ judge:
weight: 10
```
url:代码运行API地址
weight:权重
url:[judge服务](../judge) 运行API地址
weight:权重,数字越大权重越高
### 空投配置
Expand All @@ -233,10 +271,11 @@ share:
callback: "http://192.168.1.10:8105" # 回调接口
```
verify-key:校验key
verify-key:校验key,空投服务加密通讯,需与空投服务配置保持一致
callback:回调接口
### discord 消息通知配置
### discord 消息通知配置(接收空投结果通知)
配置项:
Expand All @@ -250,9 +289,12 @@ discord:
```
active:是否启用
token:机器人token
success-channel:成功通知频道ID
failed-channel:失败通知频道ID
token:Discord 机器人token
success-channel:空投成功通知 Discord 频道ID
failed-channel:空投失败通知 Discord 频道ID
### sentry 配置
Expand All @@ -266,8 +308,10 @@ sentry:
enable-tracing: true # Enable performance tracing.
```
dsn:sentry dsn
dsn:sentry dsn 配置为空不启用
traces-sample-rate:采样率
enable-tracing:是否启用性能追踪
### 社交账号绑定配置
Expand All @@ -285,7 +329,9 @@ social:
```
wechat:微信配置
discord:discord配置
api-key:API密钥,与Auth配置一致
call-url:回调地址,Auth接口地址
32 changes: 31 additions & 1 deletion internal/auth/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Auth

授权登录模块:用户绑定Github、微信、Discord

## 编译

```bash
Expand Down Expand Up @@ -37,6 +39,7 @@ project:
callback-url: "http://127.0.0.1:8087/api"
```
1、api-key 需与decert app 模块 social configuration 配置项保持一致
2、callback-url 填写 decert app 模块接口 URL
Expand All @@ -61,8 +64,11 @@ auth:
![](https://ipfs.io/ipfs/bafybeihmyjqidtjtjt5yulxuxclfzvaucgg736fkana4wqsrntrl4w47pq/Snipaste_2023-12-19_16-43-37.png)
服务器配置:
1、部署 Auth 程序,程序的 Token 和 EncodingAESKey 与微信公众号配置保持一致
2、到微信公众号服务器配置中,配置 URL、Token 和 EncodingAESKey
(https://ipfs.io/ipfs/QmQFgHGLDBUqR8ezUpxCutKwe6mvZF7EA2G3Ln8MmLhcaX/Snipaste_2023-12-19_16-39-51.png)
### Discord 配置
Expand All @@ -79,8 +85,32 @@ auth:
```
1、进入 [DEVELOPER PORTAL](https://discord.com/developers/applications)
2、选择用户需要授权绑定的 Applications,未创建可以点击 New Application
3、进入 Applications -> Oauth2 页面复制 CLIENT ID 和 CLIENT SECRET 写入配置文件
4、Redirects 添加 decert 回调链接 https://decert.me/callback/discord
![](https://ipfs.io/ipfs/bafybeihw43kchnyicpn2m7y4o2eb6ma4sgkksaymcx6osm7igcscc35wpe/Snipaste_2023-12-19_17-14-08.png)
![](https://ipfs.io/ipfs/bafybeihw43kchnyicpn2m7y4o2eb6ma4sgkksaymcx6osm7igcscc35wpe/Snipaste_2023-12-19_17-14-08.png)
### Github 配置
Github 用户绑定配置
配置项:
```yaml
# auth configuration
auth:
github:
client-id: ""
client-secret: ""
```
1、进入 [Github OAuth Apps](https://github.com/settings/developers)
2、选择用户需要授权绑定的 Apps,未创建可以点击 New OAuth App
3、进入 Apps 页面复制 CLIENT ID 和 CLIENT SECRET 写入配置文件
4、Authorization callback URL 添加 decert 回调链接 https://decert.me/
Loading

0 comments on commit 774a0cc

Please sign in to comment.