Skip to main content

Dify.ai Guide

This guide provides detailed instructions for installing and configuring Dify.ai on your local machine using Docker. Dify.ai is an LLM (Large Language Model) application development platform that simplifies the creation and deployment of AI-powered applications.


Installation Steps

1. Install Docker and Docker Compose

If you haven't already installed Docker and Docker Compose, type the following command in terminal under Manjaro Linux:

sudo pacman -Syu --noconfirm && sudo pacman -S docker --noconfirm && yay -S docker-compose ducker --noconfirm

2. Enable & Start Docker

sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker $USER

Note: After this, user needs to log out and back in for group changes to take effect.

3. Create Directories & Clone Dify Repository

  1. Create a special directory for the Dify repository and future app files:

For example, you can navigate to the Downloads/Programs directory then open the terminal there and excute the following command:

mkdir -p Dify && cd Dify && mkdir -p postgres storage weaviate && git clone https://github.com/langgenius/dify.git
chown -R 1000:1000 postgres storage weaviate

3. Navigate to the Docker Folder

Change your current directory to the Docker folder within the cloned repository:

cd dify/docker

4. Create and Configure Environment File

Navigate back to the Docker folder and create a .env file by copying the .env.example file:

cd dify/docker
cp .env.example .env

Open the .env file in a text editor and modify the following values:

POSITION_PROVIDER_PINS=http://192.168.100.16:11434

Adjust these values according to your specific setup and requirements. Save the changes to the .env file.

5. Configure ~/.docker/config.json

Open the terminal and type:

sudo subl ~/.docker/config.json

Make sure credsStore is empty as follows:

{
"auths": {},
"credsStore": "",
"currentContext": "default",
"plugins": {
"-x-cli-hints": {
"enabled": "true"
},
"debug": {
"hooks": "exec"
},
"scout": {
"hooks": "pull,buildx build"
}
},
"features": {
"hooks": "true"
}
}

6. Start Docker Containers

Run the following command to start the Docker containers:

docker-compose up -d

This command will download the necessary Docker images and start the containers in detached mode.

7. Access the Installation Wizard

Open your web browser and navigate to:

http://localhost/install

Follow the on-screen instructions to complete the initial setup. This may include:

  • Setting up an admin account
  • Configuring database settings
  • Setting up API keys for external services

8. Restart Docker Containers

After modifying the .env file, restart the Docker containers to apply the changes:

docker-compose down
docker-compose up -d

9. Access Dify.ai

Open your web browser and go to:

http://localhost

Log in using the credentials you set up during the installation wizard. You should now have access to the Dify.ai dashboard.


Post-Installation Configuration

Setting up SSL/TLS

For production environments, it's crucial to set up SSL/TLS to encrypt traffic. You can use a reverse proxy like Nginx or Traefik to handle SSL termination.

Configuring External Services

Dify.ai may require integration with external services such as:

  • OpenAI API for language model access
  • Database systems for data storage
  • Email services for notifications

Consult the Dify.ai documentation for instructions on configuring these integrations.


Updating Dify.ai & Ollama

To update Dify.ai to the latest version, navigate to the directory where dify is installed then run the following command:

git stash && git pull origin main && cd docker && docker-compose down && docker-compose up -d --build

To update Ollama, use the following command:

sudo systemctl stop ollama && curl -fsSL https://ollama.com/install.sh | sh && sudo systemctl start ollama && sleep 5 && ollama --version

Troubleshooting

If you encounter issues during the installation or operation of Dify.ai, consider the following:

  1. Port Conflicts: Ensure all required ports (8088, etc.) are available and not used by other applications.

  2. Docker Logs: Check Docker logs for any error messages:

    docker-compose logs
  3. Environment Variables: Verify that all environment variables in the .env file are correctly set and match your system configuration.

  4. Firewall/Antivirus: Make sure your firewall or antivirus software is not blocking the required connections.

  5. Resource Constraints: Ensure your system meets the minimum resource requirements. Increase Docker's resource allocation if necessary.

  6. Network Issues: If you're behind a proxy or have restricted network access, configure Docker and Dify.ai accordingly.

  7. Permissions: Ensure the user running Docker has the necessary permissions to access required directories and resources.


Best Practices

  • Regularly backup your Dify.ai data and configurations.
  • Keep your Docker images and containers updated.
  • Monitor system resources to ensure optimal performance.
  • Implement proper security measures, especially if deploying in a production environment.

For further assistance, consult the official Dify.ai documentation, join the community forums, or reach out to the support team.