Skip to main content

Prerequisites#

Setup Docker and Docker Compose#

Before installing Dify, make sure your machine meets the following minimum system requirements:

  • CPU >= 2 Core
  • RAM >= 4 GiB
Operating SystemSoftwareExplanation
macOS 10.14 or laterDocker DesktopSet 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 platformsDocker 19.03 or later Docker Compose 1.25.1 or laterPlease 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 enabledDocker DesktopWe 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 Repository#

Run the git command to clone the Dify repository.

Start Middlewares with Docker Compose#

Start the databases, sandbox, and plugin daemon with Docker Compose before starting the backend.


Setup Backend Services#

The backend services include

  1. API Service: serving API requests for Frontend service and API accessing
  2. Worker Service: serving the aync tasks for datasets processing, workspaces, cleaning-ups etc.

Start API Service#

  1. Navigate to the api directory:

  2. Prepare the environment variable config file:

    Note

    When the frontend and backend run on different subdomains, set COOKIE_DOMAIN to the site’s top-level domain (e.g., example.com) in the .env file.

    The frontend and backend must be under the same top-level domain to share authentication cookies.

  3. Generate a random secret key and replace the value of SECRET_KEY in the .env file:

  4. Install dependencies:

    uv is used to manage dependencies. Install the required dependencies with uv by running:

    For macOS: install libmagic with brew install libmagic.

  5. Perform the database migration:

    Perform database migrations to the latest version:

  6. Start the API service:

    Expected 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

  • for macOS or Linux

    If you are using a Windows system to start the Worker service, please use the following command instead:

  • for Windows

    Expected output:

Start the Beat Service#

Additionally, if you want to debug the celery scheduled tasks or run the Schedule Trigger node, you can run the following command in another terminal to start the beat service:


Setup Web Service#

Start the web service is built for frontend pages .

Environment Preparation#

To start the web frontend service, Node.js v24 (LTS) and PNPM v12 are required.

  • Install NodeJS

    Please visit https://nodejs.org/en/download and choose the v24 installation package for your respective operating system (24.20.0 or later).

  • Install PNPM

    Follow the the installation guidance to install PNPM. Or just run this command to install pnpm with npm.

Start Web Service#

  1. Enter the web directory:

  2. Install dependencies:

  3. Prepare the environment variable configuration file
    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:

  4. Build the web service:

  5. Start the web service:

    Expected output:

Access Dify#

Access http://localhost:3000 via browsers to enjoy all the exciting features of Dify. Cheers ! 🍻