Skip to content

Commit

Permalink
feat: 添加注册登录&同步聊天数据
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerwin committed Mar 9, 2023
1 parent 54381ed commit 915f51c
Show file tree
Hide file tree
Showing 21 changed files with 1,048 additions and 147 deletions.
41 changes: 40 additions & 1 deletion docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ services:
image: chenzhaoyu94/chatgpt-web # 总是使用latest,更新时重新pull该tag镜像即可
ports:
- 3002:3002
depends_on:
- database
environment:
# 二选一
OPENAI_API_KEY: xxxx
Expand All @@ -14,14 +16,48 @@ services:
OPENAI_API_BASE_URL: xxxx
# 反向代理,可选
API_REVERSE_PROXY: xxx
# 访问权限密钥,可选
# 访问jwt加密参数,可选 不为空则允许登录 同时需要设置 MONGODB_URL
AUTH_SECRET_KEY: xxx
# 超时,单位毫秒,可选
TIMEOUT_MS: 60000
# Socks代理,可选,和 SOCKS_PROXY_PORT 一起时生效
SOCKS_PROXY_HOST: xxxx
# Socks代理端口,可选,和 SOCKS_PROXY_HOST 一起时生效
SOCKS_PROXY_PORT: xxxx
# mongodb 的连接字符串
MONGODB_URL: 'mongodb://chatgpt:xxxx@database:27017'
# 网站是否开启注册
REGISTER_ENABLED: false
# 开启注册之后 网站注册允许的邮箱后缀
REGISTER_MAILS: '@qq.com,@sina.com,@163.com'
# 开启注册之后 密码加密的盐
PASSWORD_MD5_SALT: anysalt
# 开启注册之后 超级管理邮箱
ROOT_USER: [email protected]
# 开启注册之后 网站域名 不含 / 注册的时候发送验证邮箱使用
SITE_DOMAIN: http://127.0.0.1:1002
# 开启注册之后 发送验证邮箱配置
SMTP_HOST: smtp.exmail.qq.com
SMTP_PORT: 465
SMTP_TSL: true
SMTP_USERNAME: [email protected]
SMTP_PASSWORD: xxxxxx
links:
- database

database:
image: mongo
ports:
- '27017:27017'
expose:
- '27017'
volumes:
- mongodb:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: chatgpt
MONGO_INITDB_ROOT_PASSWORD: xxxx
MONGO_INITDB_DATABASE: chatgpt

nginx:
build: nginx
image: chatgpt/nginx
Expand All @@ -33,3 +69,6 @@ services:
- ./nginx/html/:/etc/nginx/html/
links:
- app

volumes:
mongodb: {}
32 changes: 31 additions & 1 deletion service/.env
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,41 @@ API_REVERSE_PROXY=
# timeout
TIMEOUT_MS=100000

# Secret key
# Secret key for jwt
AUTH_SECRET_KEY=

# Socks Proxy Host
SOCKS_PROXY_HOST=

# Socks Proxy Port
SOCKS_PROXY_PORT=

# Databse connection string, if empty chat information only exists locally
# MONGODB_URL=mongodb://chatgpt:xxxx@yourip:port
MONGODB_URL=mongodb://chatgpt:xxxx@database:27017

# Allow anyone register
REGISTER_ENABLED=false

# The site domain, Only for registration account verification
# without end /
SITE_DOMAIN=http://127.0.0.1:1002

# Allowed Email Providers, If it is empty, any mailbox is allowed
# [email protected],@sina.com,@163.com
REGISTER_MAILS=@qq.com,@sina.com,@163.com

# Only effective if AUTH_SECRET_KEY is set
# The roon user only email
ROOT_USER=

# Password salt
PASSWORD_MD5_SALT=anysalt

# Only effective if AUTH_SECRET_KEY is set
# User register email verify
SMTP_HOST=smtp.exmail.qq.com
SMTP_PORT=465
SMTP_TSL=true
SMTP_USERNAME=[email protected]
SMTP_PASSWORD=yourpassword
3 changes: 3 additions & 0 deletions service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@
"express": "^4.18.2",
"isomorphic-fetch": "^3.0.0",
"node-fetch": "^3.3.0",
"nodemailer": "^6.9.1",
"socks-proxy-agent": "^7.0.0"
},
"devDependencies": {
"@antfu/eslint-config": "^0.35.3",
"@types/express": "^4.17.17",
"@types/mongodb": "^4.0.7",
"@types/node": "^18.14.6",
"eslint": "^8.35.0",
"jsonwebtoken": "^9.0.0",
"rimraf": "^4.3.0",
"tsup": "^6.6.3",
"typescript": "^4.9.5"
Expand Down
Loading

0 comments on commit 915f51c

Please sign in to comment.