Skip to content

Commit

Permalink
Update env templates (#27)
Browse files Browse the repository at this point in the history
* update .env template
  • Loading branch information
jokester authored Oct 27, 2024
1 parent 9254cf0 commit d765b17
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 35 deletions.
43 changes: 23 additions & 20 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# 萌翻Backend的环境变量模板
# 模板中值为 CHANGE_ME 的设置涉及安全,请一定在部署时修改
# Template of moeflow-backend env variables / 萌翻Backend的环境变量模板
# values like `change_me` SHOULD be changed. They are related to security or basic functionality.
# 模板中值为 CHANGE_ME 的设置涉及安全或基础功能,请一定在部署时修改

# 【请修改】在导出文件及邮件中显示
SITE_NAME=萌翻local
SITE_ORIGIN=https://change-me.com
# 【请修改】用于加密用户 session,请配置一个很长的密钥,建议配置为 64 位以上字母数字组成的密钥
# 可用使用 python -c 'import secrets; print(secrets.token_hex())' 命令来随机生成一个
# site name
SITE_NAME=Moeflow
SITE_ORIGIN=https://change_me.com

# encrypt key of user sessions.
SECRET_KEY=CHANGE_ME
# 【请修改】管理员邮箱,第一次启动会创建此账号,默认密码为 123123,请及时修改密码!
# 之后每次程序启动时,会将此账号设置为管理员
ADMIN_EMAIL=[email protected]
# initial password for auto-created admin user
ADMIN_INITIAL_PASSWORD=very_very_secret

# Database
MONGODB_URI='mongodb://moeflow:PLEASE_CHANGE_THIS@host-mongodb:port/moeflow?authSource=admin'
# auto-created admin user and password
ADMIN_EMAIL=change_me@change_me.com
ADMIN_INITIAL_PASSWORD=change_me

# mongodb database
MONGODB_URI='mongodb://moeflow:PLEASE_CHANGE_THIS@moeflow-mongodb:27017/moeflow?authSource=admin'

# Job Queue
CELERY_BROKER_URL="amqp://moeflow:PLEASE_CHANGE_THIS@host-rabbitmq:port/moeflow"
CELERY_BACKEND_URL='mongodb://moeflow:PLEASE_CHANGE_THIS@host-mongodb:port/moeflow?authSource=admin'
# celery job queue
CELERY_BROKER_URL="amqp://moeflow:PLEASE_CHANGE_THIS@moeflow-rabbitmq:5672/moeflow"

# -----------
# Storage 配置
Expand All @@ -31,9 +30,9 @@ STORAGE_TYPE=LOCAL_STORAGE
# - 如果绑定了 CDN 来加速 OSS,则填写绑定在 CDN 的域名
# 2. 如果STORAGE_TYPE为LOCAL_STORAGE
# - 本地储存填写绑定到服务器的域名+"/storage/",格式如:http(s)://<your-domain>.com/storage/,
# 3. 如果STORAGE_TYPE为OPENDAL: 不生效 (图片URL将由OPENDAL_STORAGE_PROVIDER决定)
STORAGE_DOMAIN=http://${DOMAIN}:${HTTP_PORT}/storage/
# (可不修改) 允许上传文件的最大大小(MB),默认 1GB
STORAGE_DOMAIN=https://change_me.org/storage/

# size limit when uploading file in MB
MAX_CONTENT_LENGTH_MB=1024

## OSS_*: STORAGE_TYPE为OSS时的配置
Expand Down Expand Up @@ -79,3 +78,7 @@ EMAIL_PASSWORD=
EMAIL_REPLY_ADDRESS=
# 网站错误报告邮箱地址
EMAIL_ERROR_ADDRESS=

# Options for experimental features. only enable if you know what you are doing.
# MIT_STORAGE_ROOT=/app/storage
# CELERY_BACKEND_URL='mongodb://moeflow:PLEASE_CHANGE_THIS@moeflow-mongodb:27017/moeflow?authSource=admin'
31 changes: 16 additions & 15 deletions .env.test.sample
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
# Env variables for tests
TESTING=YES
LOG_LEVEL=DEBUG

# site name
SITE_NAME=萌翻TEST
SITE_ORIGIN=https://test.moeflow.org
SECRET_KEY=SECRET

# encrypt key of user sessions.
SECRET_KEY=CHANGE_ME

# auto-created admin user and password
[email protected]
ADMIN_INITIAL_PASSWORD=change_me

# mongodb database
MONGODB_URI="mongomock://moeflow:[email protected]:27017/moeflow_test?authSource=admin"
# MONGODB_DB_NAME=moeflow
# MONGODB_USER=moeflow
# MONGODB_PASS=CHANGE_ME

# celery job queue
CELERY_BROKER_URL="amqp://moeflow:[email protected]:5672/moeflow" # takes precedence over other RABBITMQ_* entries
# RABBITMQ_USER=moeflow
# RABBITMQ_PASS=CHANGE_ME
# RABBITMQ_VHOST_NAME=moeflow_test

# Storage
# -----------
# Storage 配置
# -----------
STORAGE_TYPE=LOCAL_STORAGE
# STORAGE_DOMAIN: 返回给客户端的图片URL前缀
# 1. 如果STORAGE_TYPE为OSS
# - 未设置自定义域名则填写阿里云提供的 OSS 域名,格式如:https://<your-bucket-name>.<oss-region>.aliyuncs.com/
# - 如果绑定了 CDN 来加速 OSS,则填写绑定在 CDN 的域名
# 2. 如果STORAGE_TYPE为LOCAL_STORAGE
# - 本地储存填写绑定到服务器的域名+"/storage/",格式如:http(s)://<your-domain>.com/storage/,
# 3. 如果STORAGE_TYPE为OPENDAL: 不生效 (图片URL将由OPENDAL_STORAGE_PROVIDER决定)
STORAGE_DOMAIN=http://127.0.0.1:5000/storage/
# (可不修改) 允许上传文件的最大大小(MB),默认 1GB

# size limit when uploading file in MB
MAX_CONTENT_LENGTH_MB=1024

## OSS_*: STORAGE_TYPE为OSS时的配置
Expand Down Expand Up @@ -71,8 +77,3 @@ EMAIL_PASSWORD=
EMAIL_REPLY_ADDRESS=
# 网站错误报告邮箱地址
EMAIL_ERROR_ADDRESS=

# Options for non default features. only enable if you know what you are doing.
# CELERY_BROKER_URL="amqp://moeflow:PLEASE_CHANGE_THIS@moeflow-rabbitmq:5672/moeflow"
# CELERY_BACKEND_URL='mongodb://moeflow:PLEASE_CHANGE_THIS@moeflow-mongodb:27017/moeflow?authSource=admin'
# MIT_STORAGE_ROOT=/app/storage
1 change: 1 addition & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

DB_URI = (
DB_URI
# legacy config
or f"mongodb://{env['MONGODB_USER']}:{env['MONGODB_PASS']}@moeflow-mongodb:27017/{env['MONGODB_DB_NAME']}?authSource=admin"
)

Expand Down

0 comments on commit d765b17

Please sign in to comment.