DifyAI Deployment Using Coolify In VPS
This post i will try to setting up a guideline om how to deploy Dify AI in cloudflare workers. Dify AI is helpful AI Platform workbench that can support multiple task and make work more flawless
Pre-Requisites
- VPS with this specification:
- 2 Core CPU
- 2 GBs memory (RAM)
- 30+ GB of storage for the images
- Public IP
- Cloudflare Account
Use for tunneling https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/
Setting Up VPS
For recomendation of VPS based on 2024 data, can refer my docs https://ilhamsurya.wiki/docs/devops/vps/vps-benchmark-2024/. I will use quick installation for the coolify setup
Linux Deps Update
Docker here will be the main part for hosting the coolify, First things first, let’s make sure our Ubuntu server is up-to-date. Connect to your server via SSH and run the following commands:
sudo apt update
sudo apt upgrade -y
This will fetch the latest versions of the packages and upgrade them.
Docker Installation
Docker command installation
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install docker-ce -y
Check docker status
sudo systemctl status docker
Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Verify the installation with:
docker-compose --version
Coolify Installation
git clone https://github.com/coollabsio/coolify.git
cd coolify/scripts
./install.sh
After the installation, you should see something like this Make sure all pod are healty
My Issue: Coolify Pod unhealty after installation
My first time installation didnt go really smooth, i encounter the unhealty issue like this:
❌ There seems to be a failure in checking the NGINX + PHP-FPM.
curl: (7) Failed to connect to localhost port 8080 after 3 ms: Could not connect to server
HTTP Status Code: 000
2025/02/08 14:05:58 [emerg] 10079#10079: socket() [::]:8080 failed (97: Address family not supported by protocol)
nginx: [emerg] socket() [::]:8080 failed (97: Address family not supported by protocol)
curl: (7) Failed to connect to localhost port 8080 after 2 ms: Could not connect to server
2025/02/08 14:05:59 [emerg] 10087#10087: socket() [::]:8080 failed (97: Address family not supported by protocol)
nginx: [emerg] socket() [::]:8080 failed (97: Address family not supported by protocol)
2025/02/08 14:06:00 [emerg] 10102#10102: socket() [::]:8080 failed (97: Address family not supported by protocol)
nginx: [emerg] socket() [::]:8080 failed (97: Address family not supported by protocol)
2025/02/08 14:06:01 [emerg] 10110#10110: socket() [::]:8080 failed (97: Address family not supported by protocol)
nginx: [emerg] socket() [::]:8080 failed (97: Address family not supported by protocol)
So how to solve it, i checking the issue in coolify official repository and found one issue that similar with mine
After some reading in the thread. the issue is due to of my IPv6 is not avaialble. we can check it by using this command
ip a | grep inet6
If you see addresses listed, IPv6 is enabled. If not, proceed to the next steps.
Setting up IPv6 in Ubuntu
Edit the GRUB Configuration: You may need to edit the GRUB configuration file to enable IPv6. Open the file using your preferred text editor:
sudo nano /etc/default/grub
Make sure the config file is like this
GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="ipv6.disable=0"
Then reload
sudo update-grub
Next is Edit sysctl Configuration: To ensure IPv6 is enabled at boot, you can edit the sysctl configuration:
sudo nano /etc/sysctl.conf
Add or uncomment the following lines:
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
Apply sysctl Changes: Apply the changes by running:
sudo sysctl -p
Restart Your System: Reboot your system for all changes to take effect:
sudo reboot
Verify IPv6 is Enabled: After the reboot, check again:
ip a | grep inet6
Coolify Setting-Up
If the installation is completed. can access the dashboard by using: "your-vps-public-ip:8000"
Dify AI Setting Up
Turns out, Coolify + Dify take too many machine resource (Minimum 4C 4GB 50GB). This is the alternative to run Dify using docker
git clone https://github.com/langgenius/dify
Before installing Dify, make sure your machine meets the following minimum system requirements:
- CPU >= 2 Core
- RAM >= 4 GiB
The easiest way to start the Dify server is through docker compose. Before running Dify with the following commands, make sure that Docker and Docker Compose are installed on your machine:
cd dify
cd docker
cp .env.example .env
docker compose up -d
After running, you can access the Dify dashboard in your browser at http://localhost/install and start the initialization process.
Dify AI Model Configuration
To use Dify, we need Model API-KEY first to do operation. Right now i'm using Deepseek & OpenRouter. I will provide model in the docs later on https://ilhamsurya.wiki/docs/category/large-language-model-llm/
After Setting up the model. we can choose from multiple template on what to build, very powerful tools..
For this content, i will try use the knowledge-base-retriever. But before use it we need to setting up the knowledge-base first (can use multiple filetype)
Then building from template, i creating my new personal knowledge-base data. that also can be embedded into this docusaurus
Conclusion
The integration of DifyAI with Coolify allows for the creation of custom models and templates, enabling the development of sophisticated AI applications. The ability to
set up a knowledge base and leverage various model APIs enhances the functionality and adaptability of the system. This setup is particularly advantageous for those
looking to incorporate AI into their projects, offering a comprehensive platform for managing and deploying AI models.
To optimize the deployment, it is crucial to address potential issues such as IPv6 unavailability and ensure that all dependencies are correctly installed and configured. Additionally, providing detailed steps for model setup and knowledge base creation, along with security considerations, will further enhance the guide's usability.
By following this guide, i hope that reader can successfully deploy DifyAI in a VPS environment, leveraging its capabilities to streamline AI-driven workflows and enhance productivity.