App template
Dify
A platform for building LLM apps, with PostgreSQL, a queue, a code sandbox and S3 storage.
- Memory when idle
- about 1.8 GiB
- CI measures it once the app is ready and before any traffic. Leave room for more.
- Tested on
- x86 servers
Introduction
Dify is a platform for building LLM apps. You design workflows, agents and chat apps in a web editor, and publish them as web apps or APIs.
This template runs Dify behind your domain, with its API, worker, plugin daemon, code sandbox, PostgreSQL and a queue. Dify keeps documents and uploaded files in the S3-compatible storage you entered in the install form.
Values you provide
Storage endpointRequired
Existing HTTPS S3-compatible object storage endpoint on TCP 443 for documents, model encryption keys and uploaded files.
Storage regionRequired
Region for the S3-compatible storage bucket.
Storage bucketRequired
Existing private S3 bucket dedicated to this application.
Storage credentials secretRequired
Existing namespaced S3 application credentials Secret with keys access-key and secret-key.
Storage CA secretOptional
Optional existing namespaced Secret with key ca.crt, the PEM CA that signed the storage endpoint certificate. Set it for a private CA, with storageCAFile set to /storage-ca/ca.crt. Leave it empty for a publicly trusted certificate.
Default:
dify-storage-caStorage CA fileOptional
Path of the PEM CA file the storage client trusts. Set it to /storage-ca/ca.crt for a private CA from storageCASecret. Leave it empty for a publicly trusted certificate, which uses the system CA bundle.
Default:
/etc/ssl/certs/ca-certificates.crt
Made for you
These values are generated at deploy and kept in a Kubernetes Secret, shown as Secret/key.
- dify-secrets/init-password
- dify-secrets/app-key
- dify-secrets/redis-password
- dify-secrets/sandbox-key
Getting started
-
In Zeabur OSS, open the
difyservice. When Overview shows its replicas as ready, the service is up. Its domain is on the Networking tab under Public domains, for exampledify.example.com. Dify also needs its other services, such asdify-api, to be ready. -
Get the initialization password. Open the
dify-apiservice, open Variables, clickdify-secretsunder From config files and secrets, and click the eye icon next toinit-password. Without Zeabur OSS, read Secretdify-secrets, keyinit-password, with kubectl:kubectl -n <namespace> get secret dify-secrets -o jsonpath='{.data.init-password}' | base64 -d -
Open
https://dify.example.com/install. Dify asks for the initialization password first, so nobody else can claim the instance. Enter it, then create the administrator account. -
Sign in at
https://dify.example.comwith the account you created.
The other keys in dify-secrets (app-key, redis-password and sandbox-key) are for Dify’s own services. Do not share them.
Configuration
Add a model provider
Dify has no models until you connect a provider. In Dify, open Integrations > Model Provider, install the provider you use, click Add API Key, and enter your key. Dify checks the key before it makes the provider available. See Model Providers.
Back up the data
Dify keeps accounts, apps and settings in the dify-db database, which holds the two databases dify and dify_plugin. In the project, open dify-db. Under Backups, set up S3 backups. A backup of dify-db covers both databases. Documents and uploaded files are in the S3 bucket you entered in the install form, so back up that bucket with your storage service. Installed plugins are on the volume dify-plugin-storage, mounted at /app/storage.
Keep the Secret dify-secrets with the backup. Dify uses app-key to sign tokens and file URLs and to encrypt OAuth client credentials. See Create, back up, and restore databases in the Zeabur OSS docs and SECRET_KEY in the Dify docs.
Troubleshooting
The page shows 502 or does not load
Open the dify service in Zeabur OSS. Check that Overview shows its replica as ready, then read the Logs tab. If the replica is not ready, open Deployments and switch to Events. If Events show OOMKilled, the service ran out of memory. Raise Maximum memory under Settings → Compute. If the service is slow or keeps reconnecting, open the Usage tab. Near memory max means the memory is close to the limit. Raise Maximum memory the same way. Dify forwards requests to dify-api and dify-web, so check these two services and dify-worker the same way. If the domain or the certificate stays pending, see Troubleshooting on the domains page.
Without Zeabur OSS, read the logs with kubectl -n <namespace> logs deployment/dify and the events with kubectl -n <namespace> get events --sort-by=.lastTimestamp.
See Adjust replicas, resources, and health checks and View logs, events, and usage, and open a terminal in the Zeabur OSS docs.
Resources
Each service is guaranteed the first amount and can use up to the second.
dify
Ports
8080
CPU
0.1 cores to 2 cores
Memory
256 MiB to 2 GiB
dify-api
Ports
5001
CPU
0.25 cores to 2 cores
Memory
512 MiB to 2 GiB
dify-worker
Ports
–
CPU
0.25 cores to 2 cores
Memory
512 MiB to 2 GiB
dify-beat
Ports
–
CPU
0.25 cores to 2 cores
Memory
512 MiB to 2 GiB
dify-web
Ports
3000
CPU
0.1 cores to 2 cores
Memory
256 MiB to 2 GiB
dify-plugin
Ports
5002
CPU
0.25 cores to 2 cores
Memory
512 MiB to 2 GiB
dify-sandbox
Ports
8194
CPU
0.1 cores to 2 cores
Memory
256 MiB to 2 GiB
dify-proxy
Ports
3128
CPU
0.1 cores to 2 cores
Memory
256 MiB to 2 GiB
dify-dragonfly
Ports
6379
CPU
0.1 cores to 2 cores
Memory
256 MiB to 2 GiB
dify-db
Ports
5432
CPU
0.25 cores to 2 cores
Memory
512 MiB to 2 GiB
Technical details
This release
- Version
- 1.19.0
- Licence
- LicenseRef-Dify-Modified-Apache-2.0 AND BUSL-1.1 AND Apache-2.0 AND PostgreSQL
- Homepage
- github.com
- Source file
- templates/dify/template.yaml @ v0.6.3
Tested in CI
CI installs these exact files on a new cluster, waits until they are ready, then records the idle memory.
| Distribution | Platform | Kubernetes | Passed | Idle memory |
|---|---|---|---|---|
| kind | linux/amd64 | v1.37.0 | 1792 MiB |
Security
The application, Dragonfly, gateway and proxy pods are restricted. The sandbox gets a narrow, justified exception to the baseline policy. The sandbox and the proxy have no sign-in, so NetworkPolicies limit who can call them: the sandbox can reach only the proxy and DNS. Other outbound traffic is not limited. Secrets are generated, ingress uses TLS, and PostgreSQL/pgvector and Dragonfly are run by operators.
Known risks
Risk
The Dragonfly engine uses the BUSL-1.1 license, which is source-available. Its Additional Use Grant excludes offering Dragonfly to third parties as a hosted or managed service or as an in-memory data store product.
How it is handled
The template description names the license. Use it only within the pinned license grant, or get a separate license. The Apache-2.0 operator does not change the engine's license. The pinned engine version changes to Apache-2.0 on 2030-11-01.
Risk
Dragonfly keeps data in memory only, until you turn on snapshots. A restart loses queued or unacknowledged tasks, locks and cache.
How it is handled
Turn on Dragonfly backups in Zeabur OSS. DB0 (cache) and DB1 (Celery) stay separate, and cache_mode=false stops the queue from being evicted. Before a restart, stop beat and the producers, and let the workers finish their jobs. After it, check that jobs ran once and only once. Old Valkey AOF, RDB or PVC data is not imported.
Risk
The sandbox container has CAP_CHOWN and CAP_DAC_OVERRIDE. Dify's sandbox hands each Python script to its run user and then opens it as root. With DAC_OVERRIDE, root inside the sandbox can read and write files it does not own in the container.
How it is handled
Only the sandbox gets these two, next to SYS_CHROOT, SETUID and SETGID. It still drops all other capabilities, allows no privilege escalation, and runs user code as a separate user under the upstream seccomp filter.
Risk
Dify's trigger and debug Lua scripts access keys that they did not declare in KEYS.
How it is handled
Dragonfly runs with allow-undeclared-keys. These scripts run one at a time, so they can lower queue throughput.
Risk
Until Dify is set up, the first visitor can create the owner account. The console is also reachable by anyone on the internet.
How it is handled
Dify asks for INIT_PASSWORD, generated in dify-secrets/init-password, before it creates the first administrator. A visitor cannot claim the instance without it. Right after the deploy, open /install, enter that password and create the owner. The console is open to anyone who can reach the domain, and Dify has its own sign-in. To limit who can reach it, add an IP limit in the service's network settings.
Risk
The Dify license restricts running more than one workspace and changing the frontend branding.
How it is handled
The template description names the license. Use one workspace unless you have written permission from upstream. The frontend images are unmodified, so they keep the branding.
Risk
The sandbox runs code that other people write, and the SSRF proxy has no sign-in. A pod in the same namespace could call either one.
How it is handled
Each has an ingress NetworkPolicy that lets in only the Dify API, worker and beat pods. The sandbox can also reach only the proxy and DNS. These are the only NetworkPolicies in the template. Namespace isolation covers everything else.
Risk
The code runner needs root to set up a chroot and to switch to a unique identity for each run.
How it is handled
This is the only exception to the baseline policy. It gets minimal capabilities, RuntimeDefault, and the upstream inner seccomp filter. It also has a generated API key, a pod with no database credentials, egress to the proxy only, and bounded resources.
Risk
Plugins are third-party code that you trust. They can use the model integrations you have configured.
How it is handled
Keep FORCE_VERIFYING_SIGNATURE set to true. The remote debugging and remote install listener are turned off. Let only trusted administrators install plugins. All plugins share one trust boundary, and the plugin pod has a restricted identity.
Risk
The PostgreSQL manager (CloudNativePG instance manager) needs limited permissions on the Kubernetes API.
How it is handled
Use the catalog operator and its limited service account.
What the cluster needs
Zeabur OSS suggests the components a cluster is missing. Without it, install them first.