docker-compose.yaml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. x-shared-env: &shared-api-worker-env
  2. # The log level for the application. Supported values are `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`
  3. LOG_LEVEL: ${LOG_LEVEL:-INFO}
  4. # Debug mode, default is false. It is recommended to turn on this configuration for local development to prevent some problems caused by monkey patch.
  5. DEBUG: ${DEBUG:-false}
  6. # Flask debug mode, it can output trace information at the interface when turned on, which is convenient for debugging.
  7. FLASK_DEBUG: ${FLASK_DEBUG:-false}
  8. # A secretkey 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`.
  9. SECRET_KEY: ${SECRET_KEY}
  10. # Password for admin user initialization.
  11. # If left unset, admin user will not be prompted for a password when creating the initial admin account.
  12. INIT_PASSWORD: ${INIT_PASSWORD}
  13. # The base URL of console application web frontend, refers to the Console base URL of WEB service if console domain is
  14. # different from api or web app domain.
  15. # example: http://cloud.dify.ai
  16. CONSOLE_WEB_URL: ${CONSOLE_WEB_URL}
  17. # The base URL of console application api server, refers to the Console base URL of WEB service if console domain is
  18. # different from api or web app domain.
  19. # example: http://cloud.dify.ai
  20. CONSOLE_API_URL: ${CONSOLE_API_URL}
  21. # The URL prefix for Service API endpoints, refers to the base URL of the current API service if api domain is
  22. # different from console domain.
  23. # example: http://api.dify.ai
  24. SERVICE_API_URL: ${SERVICE_API_URL}
  25. # The URL prefix for Web APP frontend, refers to the Web App base URL of WEB service if web app domain is different from
  26. # console or api domain.
  27. # example: http://udify.app
  28. APP_WEB_URL: ${APP_WEB_URL}
  29. # Whether to enable the version check policy. If set to false, https://updates.dify.ai will not be called for version check.
  30. CHECK_UPDATE_URL: ${CHECK_UPDATE_URL}
  31. # Used to change the OpenAI base address, default is https://api.openai.com/v1.
  32. # When OpenAI cannot be accessed in China, replace it with a domestic mirror address,
  33. # or when a local model provides OpenAI compatible API, it can be replaced.
  34. OPENAI_API_BASE: ${OPENAI_API_BASE}
  35. # File preview or download Url prefix.
  36. # used to display File preview or download Url to the front-end or as Multi-model inputs;
  37. # Url is signed and has expiration time.
  38. FILES_URL: ${FILES_URL}
  39. # File Access Time specifies a time interval in seconds for the file to be accessed.
  40. # The default value is 300 seconds.
  41. FILES_ACCESS_TIMEOUT: ${FILES_ACCESS_TIMEOUT:-300}
  42. # When enabled, migrations will be executed prior to application startup and the application will start after the migrations have completed.
  43. MIGRATION_ENABLED: ${MIGRATION_ENABLED:-true}
  44. # Deployment environment.
  45. # Supported values are `PRODUCTION`, `TESTING`. Default is `PRODUCTION`.
  46. # Testing environment. There will be a distinct color label on the front-end page,
  47. # indicating that this environment is a testing environment.
  48. DEPLOY_ENV: ${DEPLOY_ENV:-PRODUCTION}
  49. # API service binding address, default: 0.0.0.0, i.e., all addresses can be accessed.
  50. DIFY_BIND_ADDRESS: ${DIFY_BIND_ADDRESS}
  51. # API service binding port number, default 5001.
  52. DIFY_PORT: ${DIFY_PORT}
  53. # The number of API server workers, i.e., the number of gevent workers.
  54. # Formula: number of cpu cores x 2 + 1
  55. # Reference: https://docs.gunicorn.org/en/stable/design.html#how-many-workers
  56. SERVER_WORKER_AMOUNT: ${SERVER_WORKER_AMOUNT}
  57. # Defaults to gevent. If using windows, it can be switched to sync or solo.
  58. SERVER_WORKER_CLASS: ${SERVER_WORKER_CLASS}
  59. # Similar to SERVER_WORKER_CLASS. Default is gevent.
  60. # If using windows, it can be switched to sync or solo.
  61. CELERY_WORKER_CLASS: ${CELERY_WORKER_CLASS}
  62. # Request handling timeout. The default is 200,
  63. # it is recommended to set it to 360 to support a longer sse connection time.
  64. GUNICORN_TIMEOUT: ${GUNICORN_TIMEOUT}
  65. # The number of Celery workers. The default is 1, and can be set as needed.
  66. CELERY_WORKER_AMOUNT: ${CELERY_WORKER_AMOUNT}
  67. # The configurations of postgres database connection.
  68. # It is consistent with the configuration in the 'db' service below.
  69. DB_USERNAME: ${DB_USERNAME}
  70. DB_PASSWORD: ${DB_PASSWORD}
  71. DB_HOST: ${DB_HOST}
  72. DB_PORT: ${DB_PORT}
  73. DB_DATABASE: ${DB_DATABASE}
  74. # The size of the database connection pool.
  75. # The default is 30 connections, which can be appropriately increased.
  76. SQLALCHEMY_POOL_SIZE: ${SQLALCHEMY_POOL_SIZE}
  77. # Database connection pool recycling time, the default is 3600 seconds.
  78. SQLALCHEMY_POOL_RECYCLE: ${SQLALCHEMY_POOL_RECYCLE}
  79. # Whether to print SQL, default is false.
  80. SQLALCHEMY_ECHO: ${SQLALCHEMY_ECHO}
  81. # The configurations of redis connection.
  82. # It is consistent with the configuration in the 'redis' service below.
  83. REDIS_HOST: ${REDIS_HOST}
  84. REDIS_PORT: ${REDIS_PORT:-6379}
  85. REDIS_USERNAME: ${REDIS_USERNAME}
  86. REDIS_PASSWORD: ${REDIS_PASSWORD}
  87. REDIS_USE_SSL: ${REDIS_USE_SSL}
  88. # Redis Database, default is 0. Please use a different Database from Session Redis and Celery Broker.
  89. REDIS_DB: 0
  90. # The configurations of celery broker.
  91. # Use redis as the broker, and redis db 1 for celery broker.
  92. CELERY_BROKER_URL: ${CELERY_BROKER_URL}
  93. BROKER_USE_SSL: ${BROKER_USE_SSL}
  94. # Specifies the allowed origins for cross-origin requests to the Web API, e.g. https://dify.app or * for all origins.
  95. WEB_API_CORS_ALLOW_ORIGINS: ${WEB_API_CORS_ALLOW_ORIGINS}
  96. # Specifies the allowed origins for cross-origin requests to the console API, e.g. https://cloud.dify.ai or * for all origins.
  97. CONSOLE_CORS_ALLOW_ORIGINS: ${CONSOLE_CORS_ALLOW_ORIGINS}
  98. # The type of storage to use for storing user files. Supported values are `local` and `s3` and `azure-blob` and `google-storage`, Default: `local`
  99. STORAGE_TYPE: ${STORAGE_TYPE}
  100. # The path to the local storage directory, the directory relative the root path of API service codes or absolute path. Default: `storage` or `/home/john/storage`.
  101. # only available when STORAGE_TYPE is `local`.
  102. STORAGE_LOCAL_PATH: storage
  103. # The S3 storage configurations, only available when STORAGE_TYPE is `s3`.
  104. S3_USE_AWS_MANAGED_IAM: ${S3_USE_AWS_MANAGED_IAM}
  105. S3_ENDPOINT: ${S3_ENDPOINT}
  106. S3_BUCKET_NAME: ${S3_BUCKET_NAME}
  107. S3_ACCESS_KEY: ${S3_ACCESS_KEY}
  108. S3_SECRET_KEY: ${S3_SECRET_KEY}
  109. S3_REGION: ${S3_REGION}
  110. # The Azure Blob storage configurations, only available when STORAGE_TYPE is `azure-blob`.
  111. AZURE_BLOB_ACCOUNT_NAME: ${AZURE_BLOB_ACCOUNT_NAME}
  112. AZURE_BLOB_ACCOUNT_KEY: ${AZURE_BLOB_ACCOUNT_KEY}
  113. AZURE_BLOB_CONTAINER_NAME: ${AZURE_BLOB_CONTAINER_NAME}
  114. AZURE_BLOB_ACCOUNT_URL: ${AZURE_BLOB_ACCOUNT_URL}
  115. # The Google storage configurations, only available when STORAGE_TYPE is `google-storage`.
  116. GOOGLE_STORAGE_BUCKET_NAME: ${GOOGLE_STORAGE_BUCKET_NAME}
  117. # if you want to use Application Default Credentials, you can leave GOOGLE_STORAGE_SERVICE_ACCOUNT_JSON_BASE64 empty.
  118. GOOGLE_STORAGE_SERVICE_ACCOUNT_JSON_BASE64: ${GOOGLE_STORAGE_SERVICE_ACCOUNT_JSON_BASE64}
  119. # The Alibaba Cloud OSS configurations, only available when STORAGE_TYPE is `aliyun-oss`
  120. ALIYUN_OSS_BUCKET_NAME: ${ALIYUN_OSS_BUCKET_NAME}
  121. ALIYUN_OSS_ACCESS_KEY: ${ALIYUN_OSS_ACCESS_KEY}
  122. ALIYUN_OSS_SECRET_KEY: ${ALIYUN_OSS_SECRET_KEY}
  123. ALIYUN_OSS_ENDPOINT: ${ALIYUN_OSS_ENDPOINT}
  124. ALIYUN_OSS_REGION: ${ALIYUN_OSS_REGION}
  125. ALIYUN_OSS_AUTH_VERSION: ${ALIYUN_OSS_AUTH_VERSION}
  126. # The Tencent COS storage configurations, only available when STORAGE_TYPE is `tencent-cos`.
  127. TENCENT_COS_BUCKET_NAME: ${TENCENT_COS_BUCKET_NAME}
  128. TENCENT_COS_SECRET_KEY: ${TENCENT_COS_SECRET_KEY}
  129. TENCENT_COS_SECRET_ID: ${TENCENT_COS_SECRET_ID}
  130. TENCENT_COS_REGION: ${TENCENT_COS_REGION}
  131. TENCENT_COS_SCHEME: ${TENCENT_COS_SCHEME}
  132. # The type of vector store to use. Supported values are `weaviate`, `qdrant`, `milvus`, `relyt`, `pgvector`, `chroma`, 'opensearch', 'tidb_vector'.
  133. VECTOR_STORE: ${VECTOR_STORE}
  134. # The Weaviate endpoint URL. Only available when VECTOR_STORE is `weaviate`.
  135. WEAVIATE_ENDPOINT: ${WEAVIATE_ENDPOINT}
  136. # The Weaviate API key.
  137. WEAVIATE_API_KEY: ${WEAVIATE_API_KEY}
  138. # The Qdrant endpoint URL. Only available when VECTOR_STORE is `qdrant`.
  139. QDRANT_URL: ${QDRANT_URL}
  140. # The Qdrant API key.
  141. QDRANT_API_KEY: ${QDRANT_API_KEY}
  142. # The Qdrant client timeout setting.
  143. QDRANT_CLIENT_TIMEOUT: ${QDRANT_CLIENT_TIMEOUT}
  144. # The Qdrant client enable gRPC mode.
  145. QDRANT_GRPC_ENABLED: ${QDRANT_GRPC_ENABLED}
  146. # The Qdrant server gRPC mode PORT.
  147. QDRANT_GRPC_PORT: ${QDRANT_GRPC_PORT}
  148. # Milvus configuration Only available when VECTOR_STORE is `milvus`.
  149. # The milvus host.
  150. MILVUS_HOST: ${MILVUS_HOST}
  151. # The milvus host.
  152. MILVUS_PORT: ${MILVUS_PORT}
  153. # The milvus username.
  154. MILVUS_USER: ${MILVUS_USER}
  155. # The milvus password.
  156. MILVUS_PASSWORD: ${MILVUS_PASSWORD}
  157. # The milvus tls switch.
  158. MILVUS_SECURE: ${MILVUS_SECURE}
  159. # relyt configurations
  160. RELYT_HOST: ${RELYT_HOST}
  161. RELYT_PORT: ${RELYT_PORT}
  162. RELYT_USER: ${RELYT_USER}
  163. RELYT_PASSWORD: ${RELYT_PASSWORD}
  164. RELYT_DATABASE: ${RELYT_DATABASE}
  165. # pgvector configurations
  166. PGVECTOR_HOST: ${PGVECTOR_HOST}
  167. PGVECTOR_PORT: ${PGVECTOR_PORT}
  168. PGVECTOR_USER: ${PGVECTOR_USER}
  169. PGVECTOR_PASSWORD: ${PGVECTOR_PASSWORD}
  170. PGVECTOR_DATABASE: ${PGVECTOR_DATABASE}
  171. # tidb vector configurations
  172. TIDB_VECTOR_HOST: ${TIDB_VECTOR_HOST}
  173. TIDB_VECTOR_PORT: ${TIDB_VECTOR_PORT}
  174. TIDB_VECTOR_USER: ${TIDB_VECTOR_USER}
  175. TIDB_VECTOR_PASSWORD: ${TIDB_VECTOR_PASSWORD}
  176. TIDB_VECTOR_DATABASE: ${TIDB_VECTOR_DATABASE}
  177. # oracle configurations
  178. ORACLE_HOST: ${ORACLE_HOST}
  179. ORACLE_PORT: ${ORACLE_PORT}
  180. ORACLE_USER: ${ORACLE_USER}
  181. ORACLE_PASSWORD: ${ORACLE_PASSWORD}
  182. ORACLE_DATABASE: ${ORACLE_DATABASE}
  183. # Chroma configuration
  184. CHROMA_HOST: ${CHROMA_HOST}
  185. CHROMA_PORT: ${CHROMA_PORT}
  186. CHROMA_TENANT: ${CHROMA_TENANT}
  187. CHROMA_DATABASE: ${CHROMA_DATABASE}
  188. CHROMA_AUTH_PROVIDER: ${CHROMA_AUTH_PROVIDER}
  189. CHROMA_AUTH_CREDENTIALS: ${CHROMA_AUTH_CREDENTIALS}
  190. # OpenSearch configuration
  191. OPENSEARCH_HOST: ${OPENSEARCH_HOST}
  192. OPENSEARCH_PORT: ${OPENSEARCH_PORT}
  193. OPENSEARCH_USER: ${OPENSEARCH_USER}
  194. OPENSEARCH_PASSWORD: ${OPENSEARCH_PASSWORD}
  195. OPENSEARCH_SECURE: ${OPENSEARCH_SECURE}
  196. # tencent configurations
  197. TENCENT_VECTOR_DB_URL: ${TENCENT_VECTOR_DB_URL}
  198. TENCENT_VECTOR_DB_API_KEY: ${TENCENT_VECTOR_DB_API_KEY}
  199. TENCENT_VECTOR_DB_TIMEOUT: ${TENCENT_VECTOR_DB_TIMEOUT}
  200. TENCENT_VECTOR_DB_USERNAME: ${TENCENT_VECTOR_DB_USERNAME}
  201. TENCENT_VECTOR_DB_DATABASE: ${TENCENT_VECTOR_DB_DATABASE}
  202. TENCENT_VECTOR_DB_SHARD: ${TENCENT_VECTOR_DB_SHARD}
  203. TENCENT_VECTOR_DB_REPLICAS: ${TENCENT_VECTOR_DB_REPLICAS}
  204. # Knowledge Configuration
  205. # Upload file size limit, default 15M.
  206. UPLOAD_FILE_SIZE_LIMIT: ${UPLOAD_FILE_SIZE_LIMIT}
  207. # The maximum number of files that can be uploaded at a time, default 5.
  208. UPLOAD_FILE_BATCH_LIMIT: ${UPLOAD_FILE_BATCH_LIMIT}
  209. # `dify` Dify's proprietary file extraction scheme
  210. # `Unstructured` Unstructured.io file extraction scheme
  211. ETL_TYPE: ${ETL_TYPE}
  212. # Unstructured API path, needs to be configured when ETL_TYPE is Unstructured.
  213. UNSTRUCTURED_API_URL: ${UNSTRUCTURED_API_URL}
  214. # Multi-modal Configuration
  215. # The format of the image sent when the multi-modal model is input, the default is base64, optional url.
  216. MULTIMODAL_SEND_IMAGE_FORMAT: ${MULTIMODAL_SEND_IMAGE_FORMAT}
  217. # Upload image file size limit, default 10M.
  218. UPLOAD_IMAGE_FILE_SIZE_LIMIT: ${UPLOAD_IMAGE_FILE_SIZE_LIMIT}
  219. # The DSN for Sentry error reporting. If not set, Sentry error reporting will be disabled.
  220. SENTRY_DSN: ${SENTRY_DSN}
  221. # The sample rate for Sentry events. Default: `1.0`
  222. SENTRY_TRACES_SAMPLE_RATE: ${SENTRY_TRACES_SAMPLE_RATE}
  223. # The sample rate for Sentry profiles. Default: `1.0`
  224. SENTRY_PROFILES_SAMPLE_RATE: ${SENTRY_PROFILES_SAMPLE_RATE}
  225. # Notion import configuration, support public and internal
  226. NOTION_INTEGRATION_TYPE: ${NOTION_INTEGRATION_TYPE}
  227. NOTION_CLIENT_SECRET: ${NOTION_CLIENT_SECRET}
  228. NOTION_CLIENT_ID: ${NOTION_CLIENT_ID}
  229. NOTION_INTERNAL_SECRET: ${NOTION_INTERNAL_SECRET}
  230. # Mail configuration, support: resend, smtp
  231. MAIL_TYPE: ${MAIL_TYPE}
  232. # default send from email address, if not specified
  233. MAIL_DEFAULT_SEND_FROM: ${MAIL_DEFAULT_SEND_FROM}
  234. SMTP_SERVER: ${SMTP_SERVER}
  235. SMTP_PORT: ${SMTP_PORT}
  236. SMTP_USERNAME: ${SMTP_USERNAME}
  237. SMTP_PASSWORD: ${SMTP_PASSWORD}
  238. SMTP_USE_TLS: ${SMTP_USE_TLS}
  239. SMTP_OPPORTUNISTIC_TLS: ${SMTP_OPPORTUNISTIC_TLS}
  240. # the api-key for resend (https://resend.com)
  241. RESEND_API_KEY: ${RESEND_API_KEY}
  242. RESEND_API_URL: https://api.resend.com
  243. # Indexing configuration
  244. INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: ${INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH}
  245. # Other configurations
  246. INVITE_EXPIRY_HOURS: ${INVITE_EXPIRY_HOURS}
  247. CODE_EXECUTION_ENDPOINT: ${CODE_EXECUTION_ENDPOINT:-http://sandbox:8194}
  248. CODE_EXECUTION_API_KEY: ${CODE_EXECUTION_API_KEY:-dify-sandbox}
  249. CODE_MAX_NUMBER: ${CODE_MAX_NUMBER:-9223372036854775807}
  250. CODE_MIN_NUMBER: ${CODE_MIN_NUMBER:- -9223372036854775808}
  251. CODE_MAX_STRING_LENGTH: ${CODE_MAX_STRING_LENGTH:-80000}
  252. TEMPLATE_TRANSFORM_MAX_LENGTH: ${TEMPLATE_TRANSFORM_MAX_LENGTH:-80000}
  253. CODE_MAX_STRING_ARRAY_LENGTH: ${CODE_MAX_STRING_ARRAY_LENGTH:-30}
  254. CODE_MAX_OBJECT_ARRAY_LENGTH: ${CODE_MAX_OBJECT_ARRAY_LENGTH:-30}
  255. CODE_MAX_NUMBER_ARRAY_LENGTH: ${CODE_MAX_NUMBER_ARRAY_LENGTH:-1000}
  256. SSRF_PROXY_HTTP_URL: ${SSRF_PROXY_HTTP_URL:-'http://ssrf_proxy:3128'}
  257. SSRF_PROXY_HTTPS_URL: ${SSRF_PROXY_HTTPS_URL:-'http://ssrf_proxy:3128'}
  258. services:
  259. # API service
  260. api:
  261. image: langgenius/dify-api:0.6.12
  262. restart: always
  263. environment:
  264. # Use the shared environment variables.
  265. <<: *shared-api-worker-env
  266. # Startup mode, 'api' starts the API server.
  267. MODE: api
  268. depends_on:
  269. - db
  270. - redis
  271. volumes:
  272. # Mount the storage directory to the container, for storing user files.
  273. - ./volumes/app/storage:/app/api/storage
  274. # uncomment to expose dify-api port to host
  275. # ports:
  276. # - "5001:5001"
  277. networks:
  278. - ssrf_proxy_network
  279. - default
  280. # worker service
  281. # The Celery worker for processing the queue.
  282. worker:
  283. image: langgenius/dify-api:0.6.12
  284. restart: always
  285. environment:
  286. # Use the shared environment variables.
  287. <<: *shared-api-worker-env
  288. # Startup mode, 'worker' starts the Celery worker for processing the queue.
  289. MODE: worker
  290. depends_on:
  291. - db
  292. - redis
  293. volumes:
  294. # Mount the storage directory to the container, for storing user files.
  295. - ./volumes/app/storage:/app/api/storage
  296. networks:
  297. - ssrf_proxy_network
  298. - default
  299. # Frontend web application.
  300. web:
  301. image: langgenius/dify-web:0.6.12
  302. restart: always
  303. environment:
  304. CONSOLE_API_URL: ${CONSOLE_API_URL:-}
  305. APP_API_URL: ${APP_API_URL:-}
  306. SENTRY_DSN: ${SENTRY_DSN:-}
  307. # uncomment to expose dify-web port to host
  308. # ports:
  309. # - "3000:3000"
  310. # The postgres database.
  311. db:
  312. image: postgres:15-alpine
  313. restart: always
  314. environment:
  315. PGUSER: ${PGUSER:-postgres}
  316. POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-difyai123456}
  317. POSTGRES_DB: ${POSTGRES_DB:-dify}
  318. PGDATA: ${PGDATA:-/var/lib/postgresql/data/pgdata}
  319. volumes:
  320. - ./volumes/db/data:/var/lib/postgresql/data
  321. # uncomment to expose db(postgresql) port to host
  322. # ports:
  323. # - "5432:5432"
  324. healthcheck:
  325. test: [ "CMD", "pg_isready" ]
  326. interval: 1s
  327. timeout: 3s
  328. retries: 30
  329. # The redis cache.
  330. redis:
  331. image: redis:6-alpine
  332. restart: always
  333. volumes:
  334. # Mount the redis data directory to the container.
  335. - ./volumes/redis/data:/data
  336. # Set the redis password when startup redis server.
  337. command: redis-server --requirepass ${REDIS_PASSWORD:-difyai123456}
  338. healthcheck:
  339. test: [ "CMD", "redis-cli", "ping" ]
  340. # uncomment to expose redis port to host
  341. # ports:
  342. # - "6379:6379"
  343. # The DifySandbox
  344. sandbox:
  345. image: langgenius/dify-sandbox:0.2.1
  346. restart: always
  347. environment:
  348. # The DifySandbox configurations
  349. # Make sure you are changing this key for your deployment with a strong key.
  350. # You can generate a strong key using `openssl rand -base64 42`.
  351. API_KEY: ${API_KEY:-dify-sandbox}
  352. GIN_MODE: ${GIN_MODE:-release}
  353. WORKER_TIMEOUT: ${WORKER_TIMEOUT:-15}
  354. ENABLE_NETWORK: ${ENABLE_NETWORK:-true}
  355. HTTP_PROXY: ${HTTP_PROXY:-http://ssrf_proxy:3128}
  356. HTTPS_PROXY: ${HTTPS_PROXY:-http://ssrf_proxy:3128}
  357. SANDBOX_PORT: ${SANDBOX_PORT:-8194}
  358. volumes:
  359. - ./volumes/sandbox/dependencies:/dependencies
  360. networks:
  361. - ssrf_proxy_network
  362. # ssrf_proxy server
  363. # for more information, please refer to
  364. # https://docs.dify.ai/getting-started/install-self-hosted/install-faq#id-16.-why-is-ssrf_proxy-needed
  365. ssrf_proxy:
  366. image: ubuntu/squid:latest
  367. restart: always
  368. volumes:
  369. - ./ssrf_proxy/squid.conf.template:/etc/squid/squid.conf.template
  370. - ./ssrf_proxy/docker-entrypoint.sh:/docker-entrypoint.sh
  371. entrypoint: /docker-entrypoint.sh
  372. environment:
  373. # pls clearly modify the squid env vars to fit your network environment.
  374. HTTP_PORT: ${HTTP_PORT:-3128}
  375. COREDUMP_DIR: ${COREDUMP_DIR:-/var/spool/squid}
  376. REVERSE_PROXY_PORT: ${REVERSE_PROXY_PORT:-8194}
  377. SANDBOX_HOST: ${SANDBOX_HOST:-sandbox}
  378. SANDBOX_PORT: ${SANDBOX_PORT:-8194}
  379. networks:
  380. - ssrf_proxy_network
  381. - default
  382. # The nginx reverse proxy.
  383. # used for reverse proxying the API service and Web service.
  384. nginx:
  385. image: nginx:latest
  386. restart: always
  387. volumes:
  388. - ./nginx/nginx.conf.template:/etc/nginx/nginx.conf.template
  389. - ./nginx/proxy.conf.template:/etc/nginx/proxy.conf.template
  390. - ./nginx/conf.d:/etc/nginx/conf.d
  391. - ./nginx/docker-entrypoint.sh:/docker-entrypoint.sh
  392. - ./nginx/ssl:/etc/ssl
  393. entrypoint: /docker-entrypoint.sh
  394. environment:
  395. NGINX_SERVER_NAME: ${NGINX_SERVER_NAME:-_}
  396. HTTPS_ENABLED: ${HTTPS_ENABLED:-false}
  397. NGINX_SSL_PORT: ${NGINX_SSL_PORT:-443}
  398. # You're required to add your own SSL certificates/keys to the `./nginx/ssl` directory
  399. # and modify the env vars below in .env if HTTPS_ENABLED is true.
  400. NGINX_SSL_CERT_FILENAME: ${NGINX_SSL_CERT_FILENAME:-dify.crt}
  401. NGINX_SSL_CERT_KEY_FILENAME: ${NGINX_SSL_CERT_KEY_FILENAME:-dify.key}
  402. NGINX_SSL_PROTOCOLS: ${NGINX_SSL_PROTOCOLS:-TLSv1.1 TLSv1.2 TLSv1.3}
  403. NGINX_WORKER_PROCESSES: ${NGINX_WORKER_PROCESSES:-auto}
  404. NGINX_CLIENT_MAX_BODY_SIZE: ${NGINX_CLIENT_MAX_BODY_SIZE:-15M}
  405. NGINX_KEEPALIVE_TIMEOUT: ${NGINX_KEEPALIVE_TIMEOUT:-65}
  406. NGINX_PROXY_READ_TIMEOUT: ${NGINX_PROXY_READ_TIMEOUT:-3600s}
  407. NGINX_PROXY_SEND_TIMEOUT: ${NGINX_PROXY_SEND_TIMEOUT:-3600s}
  408. depends_on:
  409. - api
  410. - web
  411. ports:
  412. - "${NGINX_PORT:-80}:80"
  413. - "${NGINX_SSL_PORT:-443}:443"
  414. # The Weaviate vector store.
  415. weaviate:
  416. image: semitechnologies/weaviate:1.19.0
  417. profiles:
  418. - weaviate
  419. restart: always
  420. volumes:
  421. # Mount the Weaviate data directory to the con tainer.
  422. - ./volumes/weaviate:/var/lib/weaviate
  423. environment:
  424. # The Weaviate configurations
  425. # You can refer to the [Weaviate](https://weaviate.io/developers/weaviate/config-refs/env-vars) documentation for more information.
  426. PERSISTENCE_DATA_PATH: ${PERSISTENCE_DATA_PATH:-/var/lib/weaviate}
  427. QUERY_DEFAULTS_LIMIT: ${QUERY_DEFAULTS_LIMIT:-25}
  428. AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: ${AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED:-false}
  429. DEFAULT_VECTORIZER_MODULE: ${DEFAULT_VECTORIZER_MODULE:-none}
  430. CLUSTER_HOSTNAME: ${CLUSTER_HOSTNAME:-node1}
  431. AUTHENTICATION_APIKEY_ENABLED: ${AUTHENTICATION_APIKEY_ENABLED:-true}
  432. AUTHENTICATION_APIKEY_ALLOWED_KEYS: ${AUTHENTICATION_APIKEY_ALLOWED_KEYS:-WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih}
  433. AUTHENTICATION_APIKEY_USERS: ${AUTHENTICATION_APIKEY_USERS:-hello@dify.ai}
  434. AUTHORIZATION_ADMINLIST_ENABLED: ${AUTHORIZATION_ADMINLIST_ENABLED:-true}
  435. AUTHORIZATION_ADMINLIST_USERS: ${AUTHORIZATION_ADMINLIST_USERS:-hello@dify.ai}
  436. # uncomment to expose weaviate port to host
  437. ports:
  438. - "8080:8080"
  439. # Qdrant vector store.
  440. # (if used, you need to set VECTOR_STORE to qdrant in the api & worker service.)
  441. qdrant:
  442. image: langgenius/qdrant:v1.7.3
  443. profiles:
  444. - qdrant
  445. restart: always
  446. volumes:
  447. - ./volumes/qdrant:/qdrant/storage
  448. environment:
  449. QDRANT_API_KEY: ${QDRANT_API_KEY:-difyai123456}
  450. # uncomment to expose qdrant port to host
  451. ports:
  452. - "6333:6333"
  453. - "6334:6334"
  454. # The pgvector vector database.
  455. pgvector:
  456. image: pgvector/pgvector:pg16
  457. profiles:
  458. - pgvector
  459. restart: always
  460. environment:
  461. PGUSER: ${PGVECTOR_PGUSER:-postgres}
  462. # The password for the default postgres user.
  463. POSTGRES_PASSWORD: ${PGVECTOR_POSTGRES_PASSWORD:-difyai123456}
  464. # The name of the default postgres database.
  465. POSTGRES_DB: ${PGVECTOR_POSTGRES_DB:-dify}
  466. # postgres data directory
  467. PGDATA: ${PGVECTOR_PGDATA:-/var/lib/postgresql/data/pgdata}
  468. volumes:
  469. - ./volumes/pgvector/data:/var/lib/postgresql/data
  470. # uncomment to expose db(postgresql) port to host
  471. ports:
  472. - "5433:5432"
  473. healthcheck:
  474. test: [ "CMD", "pg_isready" ]
  475. interval: 1s
  476. timeout: 3s
  477. retries: 30
  478. # pgvecto-rs vector store
  479. pgvecto-rs:
  480. image: tensorchord/pgvecto-rs:pg16-v0.2.0
  481. profiles:
  482. - pgvecto-rs
  483. restart: always
  484. environment:
  485. PGUSER: ${PGUSER:-postgres}
  486. # The password for the default postgres user.
  487. POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-difyai123456}
  488. # The name of the default postgres database.
  489. POSTGRES_DB: ${POSTGRES_DB:-dify}
  490. # postgres data directory
  491. PGDATA: ${PGDATA:-/var/lib/postgresql/data/pgdata}
  492. volumes:
  493. - ./volumes/pgvecto_rs/data:/var/lib/postgresql/data
  494. # uncomment to expose db(postgresql) port to host
  495. ports:
  496. - "5431:5432"
  497. healthcheck:
  498. test: [ "CMD", "pg_isready" ]
  499. interval: 1s
  500. timeout: 3s
  501. retries: 30
  502. # Chroma vector database
  503. chroma:
  504. image: ghcr.io/chroma-core/chroma:0.5.1
  505. profiles:
  506. - chroma
  507. restart: always
  508. volumes:
  509. - ./volumes/chroma:/chroma/chroma
  510. environment:
  511. CHROMA_SERVER_AUTHN_CREDENTIALS: ${CHROMA_SERVER_AUTHN_CREDENTIALS:-difyai123456}
  512. CHROMA_SERVER_AUTHN_PROVIDER: ${CHROMA_SERVER_AUTHN_PROVIDER:-chromadb.auth.token_authn.TokenAuthenticationServerProvider}
  513. IS_PERSISTENT: ${IS_PERSISTENT:-TRUE}
  514. ports:
  515. - "8000:8000"
  516. oracle:
  517. image: container-registry.oracle.com/database/free:latest
  518. profiles:
  519. - oracle
  520. restart: always
  521. ports:
  522. - 1521:1521
  523. volumes:
  524. - type: volume
  525. source: oradata
  526. target: /opt/oracle/oradata
  527. - ./startupscripts:/opt/oracle/scripts/startup
  528. environment:
  529. - ORACLE_PWD=${ORACLE_PWD:-Dify123456}
  530. - ORACLE_CHARACTERSET=${ORACLE_CHARACTERSET:-AL32UTF8}
  531. # Milvus vector database services
  532. etcd:
  533. container_name: milvus-etcd
  534. image: quay.io/coreos/etcd:v3.5.5
  535. profiles:
  536. - milvus
  537. environment:
  538. - ETCD_AUTO_COMPACTION_MODE=${ETCD_AUTO_COMPACTION_MODE:-revision}
  539. - ETCD_AUTO_COMPACTION_RETENTION=${ETCD_AUTO_COMPACTION_RETENTION:-1000}
  540. - ETCD_QUOTA_BACKEND_BYTES=${ETCD_QUOTA_BACKEND_BYTES:-4294967296}
  541. - ETCD_SNAPSHOT_COUNT=${ETCD_SNAPSHOT_COUNT:-50000}
  542. volumes:
  543. - ./volumes/milvus/etcd:/etcd
  544. command: etcd -advertise-client-urls=http://127.0.0.1:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd
  545. healthcheck:
  546. test: ["CMD", "etcdctl", "endpoint", "health"]
  547. interval: 30s
  548. timeout: 20s
  549. retries: 3
  550. networks:
  551. - milvus
  552. minio:
  553. container_name: milvus-minio
  554. image: minio/minio:RELEASE.2023-03-20T20-16-18Z
  555. profiles:
  556. - milvus
  557. environment:
  558. MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin}
  559. MINIO_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin}
  560. ports:
  561. - "9001:9001"
  562. - "9000:9000"
  563. volumes:
  564. - ./volumes/milvus/minio:/minio_data
  565. command: minio server /minio_data --console-address ":9001"
  566. healthcheck:
  567. test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
  568. interval: 30s
  569. timeout: 20s
  570. retries: 3
  571. networks:
  572. - milvus
  573. milvus-standalone:
  574. container_name: milvus-standalone
  575. image: milvusdb/milvus:v2.3.1
  576. profiles:
  577. - milvus
  578. command: ["milvus", "run", "standalone"]
  579. environment:
  580. ETCD_ENDPOINTS: ${ETCD_ENDPOINTS:-etcd:2379}
  581. MINIO_ADDRESS: ${MINIO_ADDRESS:-minio:9000}
  582. common.security.authorizationEnabled: ${MILVUS_AUTHORIZATION_ENABLED:-true}
  583. volumes:
  584. - ./volumes/milvus/milvus:/var/lib/milvus
  585. healthcheck:
  586. test: ["CMD", "curl", "-f", "http://localhost:9091/healthz"]
  587. interval: 30s
  588. start_period: 90s
  589. timeout: 20s
  590. retries: 3
  591. ports:
  592. - "19530:19530"
  593. - "9091:9091"
  594. depends_on:
  595. - "etcd"
  596. - "minio"
  597. networks:
  598. - milvus
  599. opensearch:
  600. container_name: opensearch
  601. image: opensearchproject/opensearch:latest
  602. profiles:
  603. - opensearch
  604. environment:
  605. - discovery.type=${OPENSEARCH_DISCOVERY_TYPE:-single-node}
  606. - bootstrap.memory_lock=${OPENSEARCH_BOOTSTRAP_MEMORY_LOCK:-true}
  607. - OPENSEARCH_JAVA_OPTS=-Xms${OPENSEARCH_JAVA_OPTS_MIN:-512m} -Xmx${OPENSEARCH_JAVA_OPTS_MAX:-1024m}
  608. - OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_INITIAL_ADMIN_PASSWORD:-Qazwsxedc!@#123}
  609. ulimits:
  610. memlock:
  611. soft: ${OPENSEARCH_MEMLOCK_SOFT:--1}
  612. hard: ${OPENSEARCH_MEMLOCK_HARD:--1}
  613. nofile:
  614. soft: ${OPENSEARCH_NOFILE_SOFT:-65536}
  615. hard: ${OPENSEARCH_NOFILE_HARD:-65536}
  616. volumes:
  617. - ./volumes/opensearch/data:/usr/share/opensearch/data
  618. ports:
  619. - "9200:9200"
  620. - "9600:9600"
  621. networks:
  622. - opensearch-net
  623. opensearch-dashboards:
  624. container_name: opensearch-dashboards
  625. image: opensearchproject/opensearch-dashboards:latest
  626. profiles:
  627. - opensearch
  628. ports:
  629. - "5601:5601"
  630. expose:
  631. - "5601"
  632. environment:
  633. OPENSEARCH_HOSTS: '["https://opensearch:9200"]'
  634. volumes:
  635. - ./volumes/opensearch/opensearch_dashboards.yml:/usr/share/opensearch-dashboards/config/opensearch_dashboards.yml
  636. networks:
  637. - opensearch-net
  638. depends_on:
  639. - opensearch
  640. networks:
  641. # create a network between sandbox, api and ssrf_proxy, and can not access outside.
  642. ssrf_proxy_network:
  643. driver: bridge
  644. internal: true
  645. milvus:
  646. driver: bridge
  647. opensearch-net:
  648. driver: bridge
  649. internal: true
  650. volumes:
  651. oradata: