Start with Local Source Code
Prerequisites
Before installing Dify, make sure your machine meets the following minimum system requirements:
CPU >= 2 Core
RAM >= 4 GiB
macOS 10.14 or later
Docker Desktop
Set the Docker virtual machine (VM) to use a minimum of 2 virtual CPUs (vCPUs) and 8 GB of initial memory. Otherwise, the installation may fail. For more information, please refer to the Docker Desktop installation guide for Mac.
Linux platforms
Docker 19.03 or later Docker Compose 1.25.1 or later
Please refer to the Docker installation guide and the Docker Compose installation guide for more information on how to install Docker and Docker Compose, respectively.
Windows with WSL 2 enabled
Docker Desktop
We recommend storing the source code and other data that is bound to Linux containers in the Linux file system rather than the Windows file system. For more information, please refer to the Docker Desktop installation guide for using the WSL 2 backend on Windows.
If you need to use OpenAI TTS,
FFmpeg
must be installed on the system for it to function properly. For more details, refer to: Link.
Clone Dify
Before enabling business services, we need to first deploy PostgreSQL / Redis / Weaviate (if not locally available). We can start them with the following commands:
Server Deployment
API Interface Service
Worker Asynchronous Queue Consumption Service
Installation of the basic environment:
Server startup requires Python 3.11 or 3.12. It is recommended to use pyenv for quick installation of the Python environment.
To install additional Python versions, use pyenv install.
To switch to the "3.11" Python environment, use the following command:
Follow these steps :
Navigate to the "api" directory:
Copy the environment variable configuration file:
Generate a random secret key and replace the value of SECRET_KEY in the .env file:
Install the required dependencies:
Dify API service uses Poetry to manage dependencies. You can execute
poetry shell
to activate the environment.Perform the database migration:
Perform database migration to the latest version:
Start the API server:
output:
Start the Worker service
To consume asynchronous tasks from the queue, such as dataset file import and dataset document updates, follow these steps to start the Worker service on Linux or macOS:
If you are using a Windows system to start the Worker service, please use the following command instead:
output:
Deploy the frontend page
Start the web frontend client page service
Installation of the basic environment:
To start the web frontend service, you will need Node.js v18.x (LTS) and NPM version 8.x.x or Yarn.
Install NodeJS + NPM
Please visit https://nodejs.org/en/download and choose the installation package for your respective operating system that is v18.x or higher. It is recommended to download the stable version, which includes NPM by default.
Follow these steps :
Enter the web directory
Install the dependencies.
Configure the environment variables. Create a file named .env.local in the current directory and copy the contents from .env.example. Modify the values of these environment variables according to your requirements:
Build the code
Start the web service
After successful startup, the terminal will output the following information:
Access Dify
Finally, access http://127.0.0.1:3000 to use the locally deployed Dify.
Last updated