Dify.ai, a self-hosted prompt-management tool
-
For folks who need to self host this app, I created a comprehensive tutorial.
Create a fresh server, update and upgrade the system, install docker and docker compose with this one command.
sudo apt-get update -y &&
sudo apt-get upgrade -y &&
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common gnupg lsb-release &&
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg &&
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null &&
sudo apt-get update -y &&
sudo apt-get install -y docker-ce &&
sudo usermod -aG docker $USER &&
sudo curl -L https://github.com/docker/compose/releases/download/v2.26.1/docker-compose-`uname -s-uname -m` -o /usr/local/bin/docker-compose &&
sudo chmod +x /usr/local/bin/docker-compose && \Clone the Repo
git clone https://github.com/langgenius/dify.git
Customize the .env file
cd dify/docker
cp .env.example .envI only customized the following variables.
APP_WEB_URL=your_domain_name
NGINX_HTTPS_ENABLED=true
NGINX_SSL_CERT_FILENAME=cert.pem
NGINX_SSL_CERT_KEY_FILENAME=key.pemCtrl S to save, Ctrl X to exit the nano editor.
cd -Create SSL Certificate
Create ssl certificate at Cloudflare (open SSL/TSL tab and open Original Server)
nano dify/docker/nginx/ssl/cert.pem
Copy and paste the Cloudflare certificate, then Ctrl S, Ctrl Xnano dify/docker/nginx/ssl/key.pem
Copy and paste the Cloudflare SSL key, then Ctrl S, Ctrl XDeploy
cd dify/docker
docker compose up -dUpgrade
cd dify/docker
docker compose down
git pull origin main
docker compose pull
docker compose up -dSetting Up Automated Backups for Dify Using Restic and Cloudflare R2
Step 1: Install Restic
- Connect to your server via SSH.
- Update your package list and install Restic:
sudo apt update sudo apt install restic
Step 2: Prepare Your Cloudflare R2 Bucket
- Create a new R2 bucket in your Cloudflare account if you haven't already.
- Note down the following information from your Cloudflare R2 setup:
- Bucket name
- Access Key ID
- Secret Access Key
- R2 Endpoint URL
Step 3: Create the Backup Script
-
Create a new directory for the Restic script:
mkdir -p /root/restic -
Create and open the backup script using nano:
nano /root/restic/backup.sh -
Copy and paste the following content into the file:
#!/bin/bash # Set environment variables for Restic export RESTIC_REPOSITORY="s3:YOUR_R2_ENDPOINT_URL/YOUR_BUCKET_NAME" export AWS_ACCESS_KEY_ID="YOUR_ACCESS_KEY_ID" export AWS_SECRET_ACCESS_KEY="YOUR_SECRET_ACCESS_KEY" # Set the backup source BACKUP_SOURCE="/root/dify/docker/volumes" # Perform the backup restic backup $BACKUP_SOURCE # Prune old snapshots (keep last 7 daily, last 4 weekly, and last 12 monthly backups) restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --prune # Check the repository for errors restic check -
Replace the following placeholders with your actual Cloudflare R2 information:
YOUR_R2_ENDPOINT_URL: Your Cloudflare R2 endpoint URLYOUR_BUCKET_NAME: Your R2 bucket nameYOUR_ACCESS_KEY_ID: Your R2 Access Key IDYOUR_SECRET_ACCESS_KEY: Your R2 Secret Access Key
-
Save the file and exit nano:
- Press
Ctrl + X - When prompted to save, press
Y - Press
Enterto confirm the file name
- Press
-
Make the script executable:
chmod +x /root/restic/backup.sh -
Secure the script (as it contains sensitive information):
chmod 700 /root/restic/backup.sh
Step 4: Initialize the Restic Repository
-
Set the environment variables (replace with your actual R2 information):
export RESTIC_REPOSITORY="s3:YOUR_R2_ENDPOINT_URL/YOUR_BUCKET_NAME" export AWS_ACCESS_KEY_ID="YOUR_ACCESS_KEY_ID" export AWS_SECRET_ACCESS_KEY="YOUR_SECRET_ACCESS_KEY" -
Initialize the Restic repository:
restic init
Step 5: Set Up Daily Backups
-
Open the crontab file:
crontab -e -
If prompted to select an editor, choose nano by entering the corresponding number.
-
Add the following line at the end of the file to run the backup daily at 3 AM:
0 3 * * * /root/restic/backup.sh > /root/restic/backup.log 2>&1 -
Save the file and exit nano:
- Press
Ctrl + X - When prompted to save, press
Y - Press
Enterto confirm
- Press
Verifying the Setup
To ensure everything is set up correctly:
-
Run the backup script manually:
/root/restic/backup.sh -
Check the Restic repository for snapshots:
restic snapshots
Restoring from a Backup
To restore your data:
-
List available snapshots:
restic snapshots -
Restore the latest snapshot:
restic restore latest --target /path/to/restoreReplace
/path/to/restorewith the directory where you want to restore the data.
Done.
-
Started a packaging attempt ...
-
V0.0.1 installed on my Cloudron
Couple issues to resolve.
But
-
Released v0.0.2 of my cloudron-dify package.
Available on
CustomAppGatewayand/or your ownCCAI-Papp, if installed. Or one-liner installation :
curl -fsSL https://customappgateway.appx.uk/install.sh | bash -s -- --install-app "dify"Still early days on cloudron deployment, but releasing it so early-adopters can help flush out issues.
It's a large docker image, so be patient with installation.
issues :
- need to check email setup
- need to actually use it !
- Investigating the connection to Dify Marketplace (seems off)
-
released v0.0.6
plugin installation fixed for installing from local (just download from marketplace and then install the local plugin package file)Investigating the direct marketplace link
-
@timconsidine Have you ever built a knowledge base? All my files are stuck in some kind of queue. They never get processed.
-
@timconsidine Have you ever built a knowledge base? All my files are stuck in some kind of queue. They never get processed.
-
@timconsidine Have you ever built a knowledge base? All my files are stuck in some kind of queue. They never get processed.
-
@luckow
I pushed v0.0.23 to git repo
marketplace access and install
my cloudron hosted ollama set as model provider (needs open-ai-compatible plugin)
set my Ollama for nomic-text-embed
created knowledge with a single document

doc stuck in queueInvestigating ....
-
@timconsidine Have you ever built a knowledge base? All my files are stuck in some kind of queue. They never get processed.
@luckow
Think I have resolved knowledge import / indexing
Not tested heavily but I got a single 1Mb PDF through the process.Pushed 0.0.24 to GitHub
Also created new docker image :
tcmbp132021/cloudron-dify:v0.0.24 (or :latest)
Still working on a fix to sandbox for workflows but best to get the knowledge RAG out in the wild for additional testing.
-
Sandbox issue resolved
Pushed v0.0.25
tcmbp132021/cloudron-dify:v0.0.25 (or :latest)
More real-world testing needed, but hopefully we're making progress towards a v1.0.0 release
Install via 1 line install :
curl -fsSL https://customappgateway.appx.uk/install.sh | bash -s -- --install-app "dify" -
Added Playwright to the build (so playwright plugin can be used : needs URI in plugin config of
ws://localhost:3003)pushed v0.0.28
tcmbp132021/cloudron-dify:v0.0.28 (or :latest) -
Added Playwright to the build (so playwright plugin can be used : needs URI in plugin config of
ws://localhost:3003)pushed v0.0.28
tcmbp132021/cloudron-dify:v0.0.28 (or :latest)@timconsidine will look into it later.
-
Added Playwright to the build (so playwright plugin can be used : needs URI in plugin config of
ws://localhost:3003)pushed v0.0.28
tcmbp132021/cloudron-dify:v0.0.28 (or :latest)@timconsidine anything wrong on my side?
Installing App to diffy.example.org ... Image: tcmbp132021/cloudron-dify:latest ā Installation failed: No such route Details: { "status": "Not Found", "message": "No such route" }This it the output of
curl -fsSL https://customappgateway.appx.uk/install.sh | bash -s -- --install-app "Dify AI"but same error from insie CCAI-P -
@timconsidine anything wrong on my side?
Installing App to diffy.example.org ... Image: tcmbp132021/cloudron-dify:latest ā Installation failed: No such route Details: { "status": "Not Found", "message": "No such route" }This it the output of
curl -fsSL https://customappgateway.appx.uk/install.sh | bash -s -- --install-app "Dify AI"but same error from insie CCAI-P -
@timconsidine anything wrong on my side?
Installing App to diffy.example.org ... Image: tcmbp132021/cloudron-dify:latest ā Installation failed: No such route Details: { "status": "Not Found", "message": "No such route" }This it the output of
curl -fsSL https://customappgateway.appx.uk/install.sh | bash -s -- --install-app "Dify AI"but same error from insie CCAI-P% curl -fsSL https://customappgateway.appx.uk/install.sh | bash -s -- --install-app "Dify AI" CustomAppGateway Universal Installer ---------------------------------------- Detected OS: Darwin (arm64) Downloading installer from: https://customappgateway.appx.uk/cag-installer-macos Running Installer... ---------------------------------------- Welcome to the Custom App Gateway (CAG) Installer ----------------------------------------------- Fetching catalogue to find app: Dify AI... ā Found App: Dify AI (undefined) NOTE: You will need an API Token from your Cloudron Profile. Go to https://my.your-cloudron.com/#/profile to generate one. ? Enter your Cloudron Domain (e.g., my.example.com): my.example.uk ? Enter your Cloudron API Token: **************************************************************** ? Enter the subdomain to install the app (e.g., ccai.example.com): jumble.xapps.uk Validating connection... ā Connection successful Fetching App Manifest... Fetching manifest from: https://customappgateway.appx.uk/deploy/dify/CloudronManifest.json ā Manifest fetched successfully Resolving manifest file references... Installing App to jumble.xapps.uk... Image: tcmbp132021/cloudron-dify:latest ā Installation Started! (This may take a few minutes) App ID: 35125028-84f0-4fb7-a307-eb6adaa6d691 You can check the progress in your Cloudron Dashboard. Please wait for the app to enter "Running" state before using it. SECURITY REMINDER: Please DELETE the API Token you used for this installation now. ---------------------------------------- Cleaning up... Done.Takes a while to download image because it's a BIG image.
Then :
So ... I don't know for sure
but I would suspect network issue somewhere. -
@timconsidine anything wrong on my side?
Installing App to diffy.example.org ... Image: tcmbp132021/cloudron-dify:latest ā Installation failed: No such route Details: { "status": "Not Found", "message": "No such route" }This it the output of
curl -fsSL https://customappgateway.appx.uk/install.sh | bash -s -- --install-app "Dify AI"but same error from insie CCAI-PInstalling App to diffy.example.org ...
Image: tcmbp132021/cloudron-dify:latest
ā Installation failed: No such route[I assume
diffy.example.orgis just obfuscation for the forum.
]Compared to this :
Installing App to jumble.xapps.uk...
Image: tcmbp132021/cloudron-dify:latest
Installation Started! (This may take a few minutes)I think this suggests / confirms network issue.
Try again, maybe ?The first part of the sequence (the script) runs in seconds, so re-trying is do-able.
The second part (the cloudron install) takes few minutes because of image size.Are you running the install on your desktop/laptop ? Or on your Cloudron instance ?
Either way, I suspect temporary network failure connecting to hub.docker.com
Edit : I would do some standard network diagnostics.
% ping hub.docker.com
PING hub.docker.com.cdn.cloudflare.net (104.18.43.187): 56 data bytes
64 bytes from 104.18.43.187: icmp_seq=0 ttl=58 time=11.143 ms
64 bytes from 104.18.43.187: icmp_seq=1 ttl=58 time=11.543 ms
64 bytes from 104.18.43.187: icmp_seq=2 ttl=58 time=10.148 ms
^C
--- hub.docker.com.cdn.cloudflare.net ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 10.148/10.945/11.543/0.587 ms
Hmmm, possibly a Cloudflare issue ?
-
Installing App to diffy.example.org ...
Image: tcmbp132021/cloudron-dify:latest
ā Installation failed: No such route[I assume
diffy.example.orgis just obfuscation for the forum.
]Compared to this :
Installing App to jumble.xapps.uk...
Image: tcmbp132021/cloudron-dify:latest
Installation Started! (This may take a few minutes)I think this suggests / confirms network issue.
Try again, maybe ?The first part of the sequence (the script) runs in seconds, so re-trying is do-able.
The second part (the cloudron install) takes few minutes because of image size.Are you running the install on your desktop/laptop ? Or on your Cloudron instance ?
Either way, I suspect temporary network failure connecting to hub.docker.com
Edit : I would do some standard network diagnostics.
% ping hub.docker.com
PING hub.docker.com.cdn.cloudflare.net (104.18.43.187): 56 data bytes
64 bytes from 104.18.43.187: icmp_seq=0 ttl=58 time=11.143 ms
64 bytes from 104.18.43.187: icmp_seq=1 ttl=58 time=11.543 ms
64 bytes from 104.18.43.187: icmp_seq=2 ttl=58 time=10.148 ms
^C
--- hub.docker.com.cdn.cloudflare.net ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 10.148/10.945/11.543/0.587 ms
Hmmm, possibly a Cloudflare issue ?
@timconsidine can you check your chats?
-
% curl -fsSL https://customappgateway.appx.uk/install.sh | bash -s -- --install-app "Dify AI" CustomAppGateway Universal Installer ---------------------------------------- Detected OS: Darwin (arm64) Downloading installer from: https://customappgateway.appx.uk/cag-installer-macos Running Installer... ---------------------------------------- Welcome to the Custom App Gateway (CAG) Installer ----------------------------------------------- Fetching catalogue to find app: Dify AI... ā Found App: Dify AI (undefined) NOTE: You will need an API Token from your Cloudron Profile. Go to https://my.your-cloudron.com/#/profile to generate one. ? Enter your Cloudron Domain (e.g., my.example.com): my.example.uk ? Enter your Cloudron API Token: **************************************************************** ? Enter the subdomain to install the app (e.g., ccai.example.com): jumble.xapps.uk Validating connection... ā Connection successful Fetching App Manifest... Fetching manifest from: https://customappgateway.appx.uk/deploy/dify/CloudronManifest.json ā Manifest fetched successfully Resolving manifest file references... Installing App to jumble.xapps.uk... Image: tcmbp132021/cloudron-dify:latest ā Installation Started! (This may take a few minutes) App ID: 35125028-84f0-4fb7-a307-eb6adaa6d691 You can check the progress in your Cloudron Dashboard. Please wait for the app to enter "Running" state before using it. SECURITY REMINDER: Please DELETE the API Token you used for this installation now. ---------------------------------------- Cleaning up... Done.Takes a while to download image because it's a BIG image.
Then :
So ... I don't know for sure
but I would suspect network issue somewhere.@timconsidine same on the third network:
curl -fsSL https://customappgateway.appx.uk/install.sh | bash -s -- --install-app "Dify AI" CustomAppGateway Universal Installer ---------------------------------------- Detected OS: Linux (x86_64) Downloading installer from: https://customappgateway.appx.uk/cag-installer-linux Running Installer... ---------------------------------------- Welcome to the Custom App Gateway (CAG) Installer ----------------------------------------------- Fetching catalogue to find app: Dify AI... ā Found App: Dify AI (undefined) NOTE: You will need an API Token from your Cloudron Profile. Go to https://my.your-cloudron.com/#/profile to generate one. ? Enter your Cloudron Domain (e.g., my.example.com): my.example.org ? Enter your Cloudron API Token: **************************************************************** ? Enter the subdomain to install the app (e.g., ccai.example.com): dify.example.org Validating connection... ā Connection successful Fetching App Manifest... Fetching manifest from: https://customappgateway.appx.uk/deploy/dify/CloudronManifest.json ā Manifest fetched successfully Resolving manifest file references... Installing App to dify.example.org... Image: tcmbp132021/cloudron-dify:latest ā Installation failed: No such route Details: { "status": "Not Found", "message": "No such route" }ping hub.docker.com PING hub.docker.com (2606:4700:4409::ac40:9045) 56 Datenbytes 64 Bytes von 2606:4700:4409::ac40:9045: icmp_seq=1 ttl=56 Zeit=43.1 ms 64 Bytes von 2606:4700:4409::ac40:9045: icmp_seq=2 ttl=56 Zeit=48.4 ms 64 Bytes von 2606:4700:4409::ac40:9045: icmp_seq=3 ttl=56 Zeit=47.0 msI have no idea what the difference is between your network and mine.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better š
Register Login
