This project simplifies Dify's installation by pre-configuring files.
Pre-configuration: The cp0204/dify-init:1.0.0 image pre-populates required files before other containers start.
Container Modification: The project modifies the mapping files and startup commands of specific containers (e.g., ssrf_proxy, nginx) to utilize the pre-configured files.
Dependency Management: Dependencies are added to ensure the dify-init container starts before the dependent containers, guaranteeing proper initialization.
docker-compose.yaml: Retains the official yaml environment variable syntax, comments, and style for easy comparison and upgrades.
docker-compose-no-env.yaml: Applies variable values directly without a .env file.
docker-compose-no-shared-env.yaml: Does not utilize shared environment variables.
name: dify
x-shared-env: &shared-api-worker-env
CONSOLE_API_URL: ''
CONSOLE_WEB_URL: ''
SERVICE_API_URL: ''
APP_API_URL: ''
APP_WEB_URL: ''
FILES_URL: ''
LOG_LEVEL: INFO
LOG_FILE: /app/logs/server.log
LOG_FILE_MAX_SIZE: '20'
LOG_FILE_BACKUP_COUNT: '5'
LOG_DATEFORMAT: '%Y-%m-%d %H:%M:%S'
LOG_TZ: UTC
DEBUG: 'false'
FLASK_DEBUG: 'false'
SECRET_KEY: sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U
INIT_PASSWORD: ''
DEPLOY_ENV: PRODUCTION
CHECK_UPDATE_URL: https://updates.dify.ai
OPENAI_API_BASE: https://api.openai.com/v1
MIGRATION_ENABLED: 'true'
FILES_ACCESS_TIMEOUT: '300'
ACCESS_TOKEN_EXPIRE_MINUTES: '60'
REFRESH_TOKEN_EXPIRE_DAYS: '30'
APP_MAX_ACTIVE_REQUESTS: '0'
APP_MAX_EXECUTION_TIME: '1200'
DIFY_BIND_ADDRESS: 0.0.0.0
DIFY_PORT: '5001'
SERVER_WORKER_AMOUNT: '1'
SERVER_WORKER_CLASS: gevent
SERVER_WORKER_CONNECTIONS: '10'
CELERY_WORKER_CLASS: ''
GUNICORN_TIMEOUT: '360'
CELERY_WORKER_AMOUNT: ''
CELERY_AUTO_SCALE: 'false'
CELERY_MAX_WORKERS: ''
CELERY_MIN_WORKERS: ''
API_TOOL_DEFAULT_CONNECT_TIMEOUT: '10'
API_TOOL_DEFAULT_READ_TIMEOUT: '60'
DB_USERNAME: postgres
DB_PASSWORD: difyai123456
DB_HOST: db
DB_PORT: '5432'
DB_DATABASE: dify
SQLALCHEMY_POOL_SIZE: '30'
SQLALCHEMY_POOL_RECYCLE: '3600'
SQLALCHEMY_ECHO: 'false'
POSTGRES_MAX_CONNECTIONS: '100'
POSTGRES_SHARED_BUFFERS: 128MB
POSTGRES_WORK_MEM: 4MB
POSTGRES_MAINTENANCE_WORK_MEM: 64MB
POSTGRES_EFFECTIVE_CACHE_SIZE: 4096MB
REDIS_HOST: redis
REDIS_PORT: '6379'
REDIS_USERNAME: ''
REDIS_PASSWORD: difyai123456
REDIS_USE_SSL: 'false'
REDIS_DB: '0'
REDIS_USE_SENTINEL: 'false'
REDIS_SENTINELS: ''
REDIS_SENTINEL_SERVICE_NAME: ''
REDIS_SENTINEL_USERNAME: ''
REDIS_SENTINEL_PASSWORD: ''
REDIS_SENTINEL_SOCKET_TIMEOUT: '0.1'
REDIS_USE_CLUSTERS: 'false'
REDIS_CLUSTERS: ''
REDIS_CLUSTERS_PASSWORD: ''
CELERY_BROKER_URL: redis://:difyai123456@redis:6379/1
BROKER_USE_SSL: 'false'
CELERY_USE_SENTINEL: 'false'
CELERY_SENTINEL_MASTER_NAME: ''
CELERY_SENTINEL_SOCKET_TIMEOUT: '0.1'
WEB_API_CORS_ALLOW_ORIGINS: '*'
CONSOLE_CORS_ALLOW_ORIGINS: '*'
STORAGE_TYPE: opendal
OPENDAL_SCHEME: fs
OPENDAL_FS_ROOT: storage
VECTOR_STORE: weaviate
WEAVIATE_ENDPOINT: http://weaviate:8080
WEAVIATE_API_KEY: WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih
UPLOAD_FILE_SIZE_LIMIT: '15'
UPLOAD_FILE_BATCH_LIMIT: '5'
ETL_TYPE: dify
UNSTRUCTURED_API_URL: ''
UNSTRUCTURED_API_KEY: ''
SCARF_NO_ANALYTICS: 'true'
PROMPT_GENERATION_MAX_TOKENS: '512'
CODE_GENERATION_MAX_TOKENS: '1024'
MULTIMODAL_SEND_FORMAT: base64
UPLOAD_IMAGE_FILE_SIZE_LIMIT: '10'
UPLOAD_VIDEO_FILE_SIZE_LIMIT: '100'
UPLOAD_AUDIO_FILE_SIZE_LIMIT: '50'
SENTRY_DSN: ''
API_SENTRY_DSN: ''
API_SENTRY_TRACES_SAMPLE_RATE: '1.0'
API_SENTRY_PROFILES_SAMPLE_RATE: '1.0'
WEB_SENTRY_DSN: ''
NOTION_INTEGRATION_TYPE: public
NOTION_CLIENT_SECRET: ''
NOTION_CLIENT_ID: ''
NOTION_INTERNAL_SECRET: ''
MAIL_TYPE: resend
MAIL_DEFAULT_SEND_FROM: ''
RESEND_API_URL: https://api.resend.com
RESEND_API_KEY: your-resend-api-key
SMTP_SERVER: ''
SMTP_PORT: '465'
SMTP_USERNAME: ''
SMTP_PASSWORD: ''
SMTP_USE_TLS: 'true'
SMTP_OPPORTUNISTIC_TLS: 'false'
INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: '4000'
INVITE_EXPIRY_HOURS: '72'
RESET_PASSWORD_TOKEN_EXPIRY_MINUTES: '5'
CODE_EXECUTION_ENDPOINT: http://sandbox:8194
CODE_EXECUTION_API_KEY: dify-sandbox
CODE_MAX_NUMBER: '9223372036854775807'
CODE_MIN_NUMBER: '-9223372036854775808'
CODE_MAX_DEPTH: '5'
CODE_MAX_PRECISION: '20'
CODE_MAX_STRING_LENGTH: '80000'
CODE_MAX_STRING_ARRAY_LENGTH: '30'
CODE_MAX_OBJECT_ARRAY_LENGTH: '30'
CODE_MAX_NUMBER_ARRAY_LENGTH: '1000'
CODE_EXECUTION_CONNECT_TIMEOUT: '10'
CODE_EXECUTION_READ_TIMEOUT: '60'
CODE_EXECUTION_WRITE_TIMEOUT: '10'
TEMPLATE_TRANSFORM_MAX_LENGTH: '80000'
WORKFLOW_MAX_EXECUTION_STEPS: '500'
WORKFLOW_MAX_EXECUTION_TIME: '1200'
WORKFLOW_CALL_MAX_DEPTH: '5'
MAX_VARIABLE_SIZE: '204800'
WORKFLOW_PARALLEL_DEPTH_LIMIT: '3'
WORKFLOW_FILE_UPLOAD_LIMIT: '10'
HTTP_REQUEST_NODE_MAX_BINARY_SIZE: '10485760'
HTTP_REQUEST_NODE_MAX_TEXT_SIZE: '1048576'
SSRF_PROXY_HTTP_URL: http://ssrf_proxy:3128
SSRF_PROXY_HTTPS_URL: http://ssrf_proxy:3128
LOOP_NODE_MAX_COUNT: '100'
TEXT_GENERATION_TIMEOUT_MS: '60000'
PGUSER: postgres
POSTGRES_PASSWORD: difyai123456
POSTGRES_DB: dify
PGDATA: /var/lib/postgresql/data/pgdata
SANDBOX_API_KEY: dify-sandbox
SANDBOX_GIN_MODE: release
SANDBOX_WORKER_TIMEOUT: '15'
SANDBOX_ENABLE_NETWORK: 'true'
SANDBOX_HTTP_PROXY: http://ssrf_proxy:3128
SANDBOX_HTTPS_PROXY: http://ssrf_proxy:3128
SANDBOX_PORT: '8194'
WEAVIATE_PERSISTENCE_DATA_PATH: /var/lib/weaviate
WEAVIATE_QUERY_DEFAULTS_LIMIT: '25'
WEAVIATE_AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
WEAVIATE_DEFAULT_VECTORIZER_MODULE: none
WEAVIATE_CLUSTER_HOSTNAME: node1
WEAVIATE_AUTHENTICATION_APIKEY_ENABLED: 'true'
WEAVIATE_AUTHENTICATION_APIKEY_ALLOWED_KEYS: WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih
WEAVIATE_AUTHENTICATION_APIKEY_USERS: [email protected]
WEAVIATE_AUTHORIZATION_ADMINLIST_ENABLED: 'true'
WEAVIATE_AUTHORIZATION_ADMINLIST_USERS: [email protected]
NGINX_SERVER_NAME: _
NGINX_HTTPS_ENABLED: 'false'
NGINX_PORT: '80'
NGINX_SSL_PORT: '443'
NGINX_SSL_CERT_FILENAME: dify.crt
NGINX_SSL_CERT_KEY_FILENAME: dify.key
NGINX_SSL_PROTOCOLS: TLSv1.1 TLSv1.2 TLSv1.3
NGINX_WORKER_PROCESSES: auto
NGINX_CLIENT_MAX_BODY_SIZE: 15M
NGINX_KEEPALIVE_TIMEOUT: '65'
NGINX_PROXY_READ_TIMEOUT: 3600s
NGINX_PROXY_SEND_TIMEOUT: 3600s
NGINX_ENABLE_CERTBOT_CHALLENGE: 'false'
SSRF_HTTP_PORT: '3128'
SSRF_COREDUMP_DIR: /var/spool/squid
SSRF_REVERSE_PROXY_PORT: '8194'
SSRF_SANDBOX_HOST: sandbox
SSRF_DEFAULT_TIME_OUT: '5'
SSRF_DEFAULT_CONNECT_TIME_OUT: '5'
SSRF_DEFAULT_READ_TIME_OUT: '5'
SSRF_DEFAULT_WRITE_TIME_OUT: '5'
EXPOSE_NGINX_PORT: '80'
EXPOSE_NGINX_SSL_PORT: '443'
POSITION_TOOL_PINS: ''
POSITION_TOOL_INCLUDES: ''
POSITION_TOOL_EXCLUDES: ''
POSITION_PROVIDER_PINS: ''
POSITION_PROVIDER_INCLUDES: ''
POSITION_PROVIDER_EXCLUDES: ''
CSP_WHITELIST: ''
CREATE_TIDB_SERVICE_JOB_ENABLED: 'false'
MAX_SUBMIT_COUNT: '100'
TOP_K_MAX_VALUE: '10'
DB_PLUGIN_DATABASE: dify_plugin
EXPOSE_PLUGIN_DAEMON_PORT: '5002'
PLUGIN_DAEMON_PORT: '5002'
PLUGIN_DAEMON_KEY: lYkiYYT6owG+71oLerGzA7GXCgOT++6ovaezWAjpCjf+Sjc3ZtU+qUEi
PLUGIN_DAEMON_URL: http://plugin_daemon:5002
PLUGIN_MAX_PACKAGE_SIZE: '52428800'
PLUGIN_PPROF_ENABLED: 'false'
PLUGIN_DEBUGGING_HOST: 0.0.0.0
PLUGIN_DEBUGGING_PORT: '5003'
EXPOSE_PLUGIN_DEBUGGING_HOST: localhost
EXPOSE_PLUGIN_DEBUGGING_PORT: '5003'
PLUGIN_DIFY_INNER_API_KEY: QaHbTe77CtuXmsfyhR7+vRjI/+XbV1AaFy691iy+kGDv2Jvy0/eAh8Y1
PLUGIN_DIFY_INNER_API_URL: http://api:5001
ENDPOINT_URL_TEMPLATE: http://localhost/e/{hook_id}
MARKETPLACE_ENABLED: 'true'
MARKETPLACE_API_URL: https://marketplace.dify.ai
FORCE_VERIFYING_SIGNATURE: 'true'
PLUGIN_PYTHON_ENV_INIT_TIMEOUT: '120'
PLUGIN_MAX_EXECUTION_TIMEOUT: '600'
PIP_MIRROR_URL: ''
services:
# init service, used for initializing the config files.
init:
container_name: dify-init
image: cp0204/dify-init:1.0.1
restart: unless-stopped
volumes:
- /DATA/AppData/dify:/configs
networks:
- dify
# API service
api:
container_name: dify-api
image: langgenius/dify-api:1.0.1
restart: unless-stopped
environment:
# Use the shared environment variables.
<<: *shared-api-worker-env
# Startup mode, 'api' starts the API server.
MODE: api
SENTRY_DSN: ''
SENTRY_TRACES_SAMPLE_RATE: '1.0'
SENTRY_PROFILES_SAMPLE_RATE: '1.0'
PLUGIN_REMOTE_INSTALL_HOST: localhost
PLUGIN_REMOTE_INSTALL_PORT: '5003'
PLUGIN_MAX_PACKAGE_SIZE: '52428800'
INNER_API_KEY_FOR_PLUGIN: QaHbTe77CtuXmsfyhR7+vRjI/+XbV1AaFy691iy+kGDv2Jvy0/eAh8Y1
depends_on:
- db
- redis
volumes:
# Mount the storage directory to the container, for storing user files.
- /DATA/AppData/dify/volumes/app/storage:/app/api/storage
networks:
- ssrf_proxy_network
- dify
# worker service
# The Celery worker for processing the queue.
worker:
container_name: dify-worker
image: langgenius/dify-api:1.0.1
restart: unless-stopped
environment:
# Use the shared environment variables.
<<: *shared-api-worker-env
# Startup mode, 'worker' starts the Celery worker for processing the queue.
MODE: worker
SENTRY_DSN: ''
SENTRY_TRACES_SAMPLE_RATE: '1.0'
SENTRY_PROFILES_SAMPLE_RATE: '1.0'
PLUGIN_MAX_PACKAGE_SIZE: '52428800'
INNER_API_KEY_FOR_PLUGIN: QaHbTe77CtuXmsfyhR7+vRjI/+XbV1AaFy691iy+kGDv2Jvy0/eAh8Y1
depends_on:
- db
- redis
volumes:
# Mount the storage directory to the container, for storing user files.
- /DATA/AppData/dify/volumes/app/storage:/app/api/storage
networks:
- ssrf_proxy_network
- dify
# Frontend web application.
web:
container_name: dify-web
image: langgenius/dify-web:1.0.1
restart: unless-stopped
environment:
CONSOLE_API_URL: ''
APP_API_URL: ''
SENTRY_DSN: ''
NEXT_TELEMETRY_DISABLED: '0'
TEXT_GENERATION_TIMEOUT_MS: '60000'
CSP_WHITELIST: ''
MARKETPLACE_API_URL: https://marketplace.dify.ai
MARKETPLACE_URL: https://marketplace.dify.ai
TOP_K_MAX_VALUE: '10'
INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: '4000'
PM2_INSTANCES: '2'
networks:
- dify
# The postgres database.
db:
container_name: dify-db
image: postgres:15-alpine
restart: unless-stopped
environment:
PGUSER: postgres
POSTGRES_PASSWORD: difyai123456
POSTGRES_DB: dify
PGDATA: /var/lib/postgresql/data/pgdata
command: >
postgres -c 'max_connections=100'
-c 'shared_buffers=128MB'
-c 'work_mem=4MB'
-c 'maintenance_work_mem=64MB'
-c 'effective_cache_size=4096MB'
volumes:
- /DATA/AppData/dify/volumes/db/data:/var/lib/postgresql/data
healthcheck:
test: ['CMD', 'pg_isready']
interval: 1s
timeout: 3s
retries: 30
networks:
- dify
# The redis cache.
redis:
container_name: dify-redis
image: redis:6-alpine
restart: unless-stopped
environment:
REDISCLI_AUTH: difyai123456
volumes:
# Mount the redis data directory to the container.
- /DATA/AppData/dify/volumes/redis/data:/data
# Set the redis password when startup redis server.
command: redis-server --requirepass difyai123456
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
networks:
- dify
# The DifySandbox
sandbox:
container_name: dify-sandbox
image: langgenius/dify-sandbox:0.2.10
restart: unless-stopped
environment:
# The DifySandbox configurations
# Make sure you are changing this key for your deployment with a strong key.
# You can generate a strong key using `openssl rand -base64 42`.
API_KEY: dify-sandbox
GIN_MODE: release
WORKER_TIMEOUT: '15'
ENABLE_NETWORK: 'true'
HTTP_PROXY: http://ssrf_proxy:3128
HTTPS_PROXY: http://ssrf_proxy:3128
SANDBOX_PORT: '8194'
volumes:
- /DATA/AppData/dify/volumes/sandbox/dependencies:/dependencies
- /DATA/AppData/dify/volumes/sandbox/conf:/conf
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:8194/health']
networks:
- ssrf_proxy_network
- dify
depends_on:
- init
# plugin daemon
plugin_daemon:
container_name: dify-plugin_daemon
image: langgenius/dify-plugin-daemon:0.0.4-local
restart: unless-stopped
environment:
# Use the shared environment variables.
<<: *shared-api-worker-env
DB_DATABASE: dify_plugin
SERVER_PORT: '5002'
SERVER_KEY: lYkiYYT6owG+71oLerGzA7GXCgOT++6ovaezWAjpCjf+Sjc3ZtU+qUEi
MAX_PLUGIN_PACKAGE_SIZE: '52428800'
PPROF_ENABLED: 'false'
DIFY_INNER_API_URL: http://api:5001
DIFY_INNER_API_KEY: QaHbTe77CtuXmsfyhR7+vRjI/+XbV1AaFy691iy+kGDv2Jvy0/eAh8Y1
PLUGIN_REMOTE_INSTALLING_HOST: 0.0.0.0
PLUGIN_REMOTE_INSTALLING_PORT: '5003'
PLUGIN_WORKING_PATH: /app/storage/cwd
FORCE_VERIFYING_SIGNATURE: 'true'
# ports:
# - "${EXPOSE_PLUGIN_DEBUGGING_PORT:-5003}:${PLUGIN_DEBUGGING_PORT:-5003}"
volumes:
- /DATA/AppData/dify/volumes/plugin_daemon:/app/storage
networks:
- dify
# ssrf_proxy server
# for more information, please refer to
# https://docs.dify.ai/learn-more/faq/install-faq#id-18.-why-is-ssrf_proxy-needed
ssrf_proxy:
container_name: dify-ssrf_proxy
image: ubuntu/squid:latest
restart: unless-stopped
volumes:
- /DATA/AppData/dify/ssrf_proxy:/init # Avoid creating files as dirs
# - /DATA/AppData/dify/ssrf_proxy/squid.conf.template:/etc/squid/squid.conf.template
# - /DATA/AppData/dify/ssrf_proxy/docker-entrypoint.sh:/docker-entrypoint-mount.sh
entrypoint: ['sh', '-c', "cp /init/squid.conf.template /etc/squid/squid.conf.template && cp /init/docker-entrypoint.sh /docker-entrypoint.sh && sed -i 's/\r$$//' /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh && /docker-entrypoint.sh"]
environment:
# pls clearly modify the squid env vars to fit your network environment.
HTTP_PORT: '3128'
COREDUMP_DIR: /var/spool/squid
REVERSE_PROXY_PORT: '8194'
SANDBOX_HOST: sandbox
SANDBOX_PORT: '8194'
networks:
- ssrf_proxy_network
- dify
depends_on:
- init
# The nginx reverse proxy.
# used for reverse proxying the API service and Web service.
nginx:
container_name: dify-nginx
image: nginx:latest
restart: unless-stopped
volumes:
- /DATA/AppData/dify/nginx:/init # Avoid creating files as dirs
# - /DATA/AppData/dify/nginx/nginx.conf.template:/etc/nginx/nginx.conf.template
# - /DATA/AppData/dify/nginx/proxy.conf.template:/etc/nginx/proxy.conf.template
# - /DATA/AppData/dify/nginx/https.conf.template:/etc/nginx/https.conf.template
- /DATA/AppData/dify/nginx/conf.d:/etc/nginx/conf.d
# - /DATA/AppData/dify/nginx/docker-entrypoint.sh:/docker-entrypoint-mount.sh
- /DATA/AppData/dify/nginx/ssl:/etc/ssl # cert dir (legacy)
entrypoint: ['sh', '-c', "cp /init/*.template /etc/nginx && cp /init/docker-entrypoint.sh /docker-entrypoint.sh && sed -i 's/\r$$//' /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh && /docker-entrypoint.sh"]
environment:
NGINX_SERVER_NAME: _
NGINX_HTTPS_ENABLED: 'false'
NGINX_SSL_PORT: '443'
NGINX_PORT: '80'
# You're required to add your own SSL certificates/keys to the `/DATA/AppData/dify/nginx/ssl` directory
# and modify the env vars below in .env if HTTPS_ENABLED is true.
NGINX_SSL_CERT_FILENAME: dify.crt
NGINX_SSL_CERT_KEY_FILENAME: dify.key
NGINX_SSL_PROTOCOLS: TLSv1.1 TLSv1.2 TLSv1.3
NGINX_WORKER_PROCESSES: auto
NGINX_CLIENT_MAX_BODY_SIZE: 15M
NGINX_KEEPALIVE_TIMEOUT: '65'
NGINX_PROXY_READ_TIMEOUT: 3600s
NGINX_PROXY_SEND_TIMEOUT: 3600s
NGINX_ENABLE_CERTBOT_CHALLENGE: 'false'
CERTBOT_DOMAIN: your_domain.com
depends_on:
- api
- web
- init
ports:
- '80:80'
# - '${EXPOSE_NGINX_SSL_PORT:-443}:${NGINX_SSL_PORT:-443}'
networks:
- dify
# The Weaviate vector store.
weaviate:
container_name: dify-weaviate
image: semitechnologies/weaviate:1.19.0
profiles:
- ''
- weaviate
restart: unless-stopped
volumes:
# Mount the Weaviate data directory to the con tainer.
- /DATA/AppData/dify/volumes/weaviate:/var/lib/weaviate
environment:
# The Weaviate configurations
# You can refer to the [Weaviate](https://weaviate.io/developers/weaviate/config-refs/env-vars) documentation for more information.
PERSISTENCE_DATA_PATH: /var/lib/weaviate
QUERY_DEFAULTS_LIMIT: '25'
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
DEFAULT_VECTORIZER_MODULE: none
CLUSTER_HOSTNAME: node1
AUTHENTICATION_APIKEY_ENABLED: 'true'
AUTHENTICATION_APIKEY_ALLOWED_KEYS: WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih
AUTHENTICATION_APIKEY_USERS: [email protected]
AUTHORIZATION_ADMINLIST_ENABLED: 'true'
AUTHORIZATION_ADMINLIST_USERS: [email protected]
networks:
- dify
networks:
# create a network between sandbox, api and ssrf_proxy, and can not access outside.
ssrf_proxy_network:
driver: bridge
internal: true
dify:
name: dify
Data is stored by default in the /DATA/AppData/dify directory.
Content type
Image
Digest
sha256:de5d119fb…
Size
2.1 MB
Last updated
over 1 year ago
docker pull cp0204/dify-init