Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
72887692
Commit
72887692
authored
Jul 13, 2023
by
John Wang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feat/send-mail' into deploy/dev
# Conflicts: # api/config.py
parents
6020a38c
85f14832
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
71 additions
and
39 deletions
+71
-39
.env.example
api/.env.example
+10
-4
Dockerfile
api/Dockerfile
+5
-3
config.py
api/config.py
+11
-7
data_source_oauth.py
api/controllers/console/auth/data_source_oauth.py
+5
-5
oauth.py
api/controllers/console/auth/oauth.py
+3
-3
members.py
api/controllers/console/workspace/members.py
+1
-1
model.py
api/models/model.py
+3
-2
mail_invite_member_task.py
api/tasks/mail_invite_member_task.py
+1
-1
docker-compose.yaml
docker/docker-compose.yaml
+17
-9
Dockerfile
web/Dockerfile
+2
-2
entrypoint.sh
web/docker/entrypoint.sh
+13
-2
No files found.
api/.env.example
View file @
72887692
...
...
@@ -8,13 +8,19 @@ EDITION=SELF_HOSTED
SECRET_KEY=
# Console API base URL
CONSOLE_URL=http://127.0.0.1:5001
CONSOLE_API_URL=http://127.0.0.1:5001
# Console frontend web base URL
CONSOLE_WEB_URL=http://127.0.0.1:3000
# Service API base URL
API_URL=http://127.0.0.1:5001
SERVICE_API_URL=http://127.0.0.1:5001
# Web APP API base URL
APP_API_URL=http://127.0.0.1:5001
# Web APP base URL
APP_URL=http://127.0.0.1:3000
# Web APP
frontend web
base URL
APP_
WEB_
URL=http://127.0.0.1:3000
# celery configuration
CELERY_BROKER_URL=redis://:difyai123456@localhost:6379/1
...
...
api/Dockerfile
View file @
72887692
...
...
@@ -5,9 +5,11 @@ LABEL maintainer="takatost@gmail.com"
ENV
FLASK_APP app.py
ENV
EDITION SELF_HOSTED
ENV
DEPLOY_ENV PRODUCTION
ENV
CONSOLE_URL http://127.0.0.1:5001
ENV
API_URL http://127.0.0.1:5001
ENV
APP_URL http://127.0.0.1:5001
ENV
CONSOLE_API_URL http://127.0.0.1:5001
ENV
CONSOLE_WEB_URL http://127.0.0.1:3000
ENV
SERVICE_API_URL http://127.0.0.1:5001
ENV
APP_API_URL http://127.0.0.1:5001
ENV
APP_WEB_URL http://127.0.0.1:3000
EXPOSE
5001
...
...
api/config.py
View file @
72887692
...
...
@@ -28,9 +28,11 @@ DEFAULTS = {
'SESSION_REDIS_USE_SSL'
:
'False'
,
'OAUTH_REDIRECT_PATH'
:
'/console/api/oauth/authorize'
,
'OAUTH_REDIRECT_INDEX_PATH'
:
'/'
,
'CONSOLE_URL'
:
'https://cloud.dify.ai'
,
'API_URL'
:
'https://api.dify.ai'
,
'APP_URL'
:
'https://udify.app'
,
'CONSOLE_WEB_URL'
:
'https://cloud.dify.ai'
,
'CONSOLE_API_URL'
:
'https://cloud.dify.ai'
,
'SERVICE_API_URL'
:
'https://api.dify.ai'
,
'APP_WEB_URL'
:
'https://udify.app'
,
'APP_API_URL'
:
'https://udify.app'
,
'STORAGE_TYPE'
:
'local'
,
'STORAGE_LOCAL_PATH'
:
'storage'
,
'CHECK_UPDATE_URL'
:
'https://updates.dify.ai'
,
...
...
@@ -76,9 +78,11 @@ class Config:
def
__init__
(
self
):
# app settings
self
.
CONSOLE_URL
=
get_env
(
'CONSOLE_URL'
)
self
.
API_URL
=
get_env
(
'API_URL'
)
self
.
APP_URL
=
get_env
(
'APP_URL'
)
self
.
CONSOLE_API_URL
=
get_env
(
'CONSOLE_API_URL'
)
if
get_env
(
'CONSOLE_API_URL'
)
else
get_env
(
'CONSOLE_URL'
)
self
.
CONSOLE_WEB_URL
=
get_env
(
'CONSOLE_WEB_URL'
)
if
get_env
(
'CONSOLE_WEB_URL'
)
else
get_env
(
'CONSOLE_URL'
)
self
.
SERVICE_API_URL
=
get_env
(
'SERVICE_API_URL'
)
if
get_env
(
'SERVICE_API_URL'
)
else
get_env
(
'API_URL'
)
self
.
APP_WEB_URL
=
get_env
(
'APP_WEB_URL'
)
if
get_env
(
'APP_WEB_URL'
)
else
get_env
(
'APP_URL'
)
self
.
APP_API_URL
=
get_env
(
'APP_API_URL'
)
if
get_env
(
'APP_API_URL'
)
else
get_env
(
'APP_URL'
)
self
.
CURRENT_VERSION
=
"0.3.7"
self
.
COMMIT_SHA
=
get_env
(
'COMMIT_SHA'
)
self
.
EDITION
=
"SELF_HOSTED"
...
...
@@ -147,7 +151,7 @@ class Config:
# cors settings
self
.
CONSOLE_CORS_ALLOW_ORIGINS
=
get_cors_allow_origins
(
'CONSOLE_CORS_ALLOW_ORIGINS'
,
self
.
CONSOLE_URL
)
'CONSOLE_CORS_ALLOW_ORIGINS'
,
self
.
CONSOLE_
WEB_
URL
)
self
.
WEB_API_CORS_ALLOW_ORIGINS
=
get_cors_allow_origins
(
'WEB_API_CORS_ALLOW_ORIGINS'
,
'*'
)
...
...
api/controllers/console/auth/data_source_oauth.py
View file @
72887692
...
...
@@ -20,7 +20,7 @@ def get_oauth_providers():
client_secret
=
current_app
.
config
.
get
(
'NOTION_CLIENT_SECRET'
),
redirect_uri
=
current_app
.
config
.
get
(
'CONSOLE_URL'
)
+
'/console/api/oauth/data-source/callback/notion'
)
'CONSOLE_
API_
URL'
)
+
'/console/api/oauth/data-source/callback/notion'
)
OAUTH_PROVIDERS
=
{
'notion'
:
notion_oauth
...
...
@@ -42,7 +42,7 @@ class OAuthDataSource(Resource):
if
current_app
.
config
.
get
(
'NOTION_INTEGRATION_TYPE'
)
==
'internal'
:
internal_secret
=
current_app
.
config
.
get
(
'NOTION_INTERNAL_SECRET'
)
oauth_provider
.
save_internal_access_token
(
internal_secret
)
return
redirect
(
f
'{current_app.config.get("CONSOLE_URL")}?oauth_data_source=success'
)
return
redirect
(
f
'{current_app.config.get("CONSOLE_
WEB_
URL")}?oauth_data_source=success'
)
else
:
auth_url
=
oauth_provider
.
get_authorization_url
()
return
redirect
(
auth_url
)
...
...
@@ -66,12 +66,12 @@ class OAuthDataSourceCallback(Resource):
f
"An error occurred during the OAuthCallback process with {provider}: {e.response.text}"
)
return
{
'error'
:
'OAuth data source process failed'
},
400
return
redirect
(
f
'{current_app.config.get("CONSOLE_URL")}?oauth_data_source=success'
)
return
redirect
(
f
'{current_app.config.get("CONSOLE_
WEB_
URL")}?oauth_data_source=success'
)
elif
'error'
in
request
.
args
:
error
=
request
.
args
.
get
(
'error'
)
return
redirect
(
f
'{current_app.config.get("CONSOLE_URL")}?oauth_data_source={error}'
)
return
redirect
(
f
'{current_app.config.get("CONSOLE_
WEB_
URL")}?oauth_data_source={error}'
)
else
:
return
redirect
(
f
'{current_app.config.get("CONSOLE_URL")}?oauth_data_source=access_denied'
)
return
redirect
(
f
'{current_app.config.get("CONSOLE_
WEB_
URL")}?oauth_data_source=access_denied'
)
class
OAuthDataSourceSync
(
Resource
):
...
...
api/controllers/console/auth/oauth.py
View file @
72887692
...
...
@@ -20,13 +20,13 @@ def get_oauth_providers():
client_secret
=
current_app
.
config
.
get
(
'GITHUB_CLIENT_SECRET'
),
redirect_uri
=
current_app
.
config
.
get
(
'CONSOLE_URL'
)
+
'/console/api/oauth/authorize/github'
)
'CONSOLE_
API_
URL'
)
+
'/console/api/oauth/authorize/github'
)
google_oauth
=
GoogleOAuth
(
client_id
=
current_app
.
config
.
get
(
'GOOGLE_CLIENT_ID'
),
client_secret
=
current_app
.
config
.
get
(
'GOOGLE_CLIENT_SECRET'
),
redirect_uri
=
current_app
.
config
.
get
(
'CONSOLE_URL'
)
+
'/console/api/oauth/authorize/google'
)
'CONSOLE_
API_
URL'
)
+
'/console/api/oauth/authorize/google'
)
OAUTH_PROVIDERS
=
{
'github'
:
github_oauth
,
...
...
@@ -80,7 +80,7 @@ class OAuthCallback(Resource):
flask_login
.
login_user
(
account
,
remember
=
True
)
AccountService
.
update_last_login
(
account
,
request
)
return
redirect
(
f
'{current_app.config.get("CONSOLE_URL")}?oauth_login=success'
)
return
redirect
(
f
'{current_app.config.get("CONSOLE_
WEB_
URL")}?oauth_login=success'
)
def
_get_account_by_openid_or_email
(
provider
:
str
,
user_info
:
OAuthUserInfo
)
->
Optional
[
Account
]:
...
...
api/controllers/console/workspace/members.py
View file @
72887692
...
...
@@ -83,7 +83,7 @@ class MemberInviteEmailApi(Resource):
'result'
:
'success'
,
'account'
:
account
,
'invite_url'
:
'{}/activate?workspace_id={}&email={}&token={}'
.
format
(
current_app
.
config
.
get
(
"CONSOLE_URL"
),
current_app
.
config
.
get
(
"CONSOLE_
WEB_
URL"
),
str
(
current_user
.
current_tenant_id
),
invitee_email
,
token
...
...
api/models/model.py
View file @
72887692
...
...
@@ -56,7 +56,8 @@ class App(db.Model):
@
property
def
api_base_url
(
self
):
return
(
current_app
.
config
[
'API_URL'
]
if
current_app
.
config
[
'API_URL'
]
else
request
.
host_url
.
rstrip
(
'/'
))
+
'/v1'
return
(
current_app
.
config
[
'SERVICE_API_URL'
]
if
current_app
.
config
[
'SERVICE_API_URL'
]
else
request
.
host_url
.
rstrip
(
'/'
))
+
'/v1'
@
property
def
tenant
(
self
):
...
...
@@ -515,7 +516,7 @@ class Site(db.Model):
@
property
def
app_base_url
(
self
):
return
(
current_app
.
config
[
'APP_
URL'
]
if
current_app
.
config
[
'APP
_URL'
]
else
request
.
host_url
.
rstrip
(
'/'
))
return
(
current_app
.
config
[
'APP_
WEB_URL'
]
if
current_app
.
config
[
'APP_WEB
_URL'
]
else
request
.
host_url
.
rstrip
(
'/'
))
class
ApiToken
(
db
.
Model
):
...
...
api/tasks/mail_invite_member_task.py
View file @
72887692
...
...
@@ -37,7 +37,7 @@ def send_invite_member_mail_task(to: str, token: str, inviter_name: str, workspa
<p>Thanks,</p>
<p>Dify Team</p>"""
.
format
(
inviter_name
=
inviter_name
,
workspace_name
=
workspace_name
,
url
=
'{}/activate?workspace_id={}&email={}&token={}'
.
format
(
current_app
.
config
.
get
(
"CONSOLE_URL"
),
current_app
.
config
.
get
(
"CONSOLE_
WEB_
URL"
),
workspace_id
,
to
,
token
)
...
...
docker/docker-compose.yaml
View file @
72887692
...
...
@@ -11,18 +11,26 @@ services:
LOG_LEVEL
:
INFO
# A secret key that is used for securely signing the session cookie and encrypting sensitive information on the database. You can generate a strong key using `openssl rand -base64 42`.
SECRET_KEY
:
sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U
# The base URL of console application, refers to the Console base URL of WEB service if console domain is
# The base URL of console application
web frontend
, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.
# example: http://cloud.dify.ai
CONSOLE_URL
:
'
'
CONSOLE_WEB_URL
:
'
'
# The base URL of console application api server, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.
# example: http://cloud.dify.ai
CONSOLE_API_URL
:
'
'
# The URL for Service API endpoints,refers to the base URL of the current API service if api domain is
# different from console domain.
# example: http://api.dify.ai
API_URL
:
'
'
# The URL for Web APP, refers to the Web App base URL of WEB service if web app domain is different from
SERVICE_API_URL
:
'
'
# The URL for Web APP api server, refers to the Web App base URL of WEB service if web app domain is different from
# console or api domain.
# example: http://udify.app
APP_API_URL
:
'
'
# The URL for Web APP frontend, refers to the Web App base URL of WEB service if web app domain is different from
# console or api domain.
# example: http://udify.app
APP_URL
:
'
'
APP_
WEB_
URL
:
'
'
# When enabled, migrations will be executed prior to application startup and the application will start after the migrations have completed.
MIGRATION_ENABLED
:
'
true'
# The configurations of postgres database connection.
...
...
@@ -172,14 +180,14 @@ services:
restart
:
always
environment
:
EDITION
:
SELF_HOSTED
# The base URL of console application, refers to the Console base URL of WEB service if console domain is
# The base URL of console application
api server
, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.
# example: http://cloud.dify.ai
CONSOLE_URL
:
'
'
# The URL for Web APP, refers to the Web App base URL of WEB service if web app domain is different from
CONSOLE_
API_
URL
:
'
'
# The URL for Web APP
api server
, refers to the Web App base URL of WEB service if web app domain is different from
# console or api domain.
# example: http://udify.app
APP_URL
:
'
'
APP_
API_
URL
:
'
'
# The DSN for Sentry error reporting. If not set, Sentry error reporting will be disabled.
SENTRY_DSN
:
'
'
...
...
web/Dockerfile
View file @
72887692
...
...
@@ -4,8 +4,8 @@ LABEL maintainer="takatost@gmail.com"
ENV
EDITION SELF_HOSTED
ENV
DEPLOY_ENV PRODUCTION
ENV
CONSOLE_URL http://127.0.0.1:5001
ENV
APP_URL http://127.0.0.1:5001
ENV
CONSOLE_
API_
URL http://127.0.0.1:5001
ENV
APP_
API_
URL http://127.0.0.1:5001
EXPOSE
3000
...
...
web/docker/entrypoint.sh
View file @
72887692
...
...
@@ -4,8 +4,19 @@ set -e
export
NEXT_PUBLIC_DEPLOY_ENV
=
${
DEPLOY_ENV
}
export
NEXT_PUBLIC_EDITION
=
${
EDITION
}
export
NEXT_PUBLIC_API_PREFIX
=
${
CONSOLE_URL
}
/console/api
export
NEXT_PUBLIC_PUBLIC_API_PREFIX
=
${
APP_URL
}
/api
if
[[
-z
"
$CONSOLE_API_URL
"
]]
;
then
export
NEXT_PUBLIC_API_PREFIX
=
${
CONSOLE_URL
}
/console/api
else
export
NEXT_PUBLIC_API_PREFIX
=
${
CONSOLE_API_URL
}
/console/api
fi
if
[[
-z
"
$APP_API_URL
"
]]
;
then
export
NEXT_PUBLIC_PUBLIC_API_PREFIX
=
${
APP_URL
}
/api
else
export
NEXT_PUBLIC_PUBLIC_API_PREFIX
=
${
APP_API_URL
}
/api
fi
export
NEXT_PUBLIC_SENTRY_DSN
=
${
SENTRY_DSN
}
/usr/local/bin/pm2
-v
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment