--- title: Dify emoji: 🐢 colorFrom: gray colorTo: red sdk: docker pinned: false --- # Dify on HuggingFace Spaces Self-hosted [Dify](https://dify.ai) (v1.14.2) running as a single Docker container on HuggingFace Spaces. ## Setup 1. Enable **Persistent Storage** in your Space settings (Settings → Persistent storage). This mounts `/data` and preserves your database, uploads, and configuration across container restarts. 2. Set the following **Secrets** in your Space settings for security: - `SECRET_KEY` — a random string (generate with `openssl rand -base64 42`) - `INIT_PASSWORD` — admin account initial password 3. The Space will build and deploy automatically. First boot takes a few minutes to initialize the database. ## Default Credentials - URL: `https://.hf.space` - Initial admin password: `dify123456` (change via `INIT_PASSWORD` secret) ## Architecture Single container running via supervisord: - **PostgreSQL 15** — application database (data at `/data/postgres`) - **Redis** — cache and Celery broker (data at `/data/redis`) - **Dify API** — Flask/Gunicorn on port 5001 - **Dify Worker** — Celery async worker - **Dify Web** — Next.js frontend on port 3000 - **Nginx** — reverse proxy on port 7860 (HF Spaces ingress port) File uploads stored at `/data/storage`. ## Configuration Override any Dify environment variable via HuggingFace Space Secrets or Variables. Common ones: - `SECRET_KEY`, `INIT_PASSWORD` - `LOG_LEVEL` (default: INFO) - `STORAGE_TYPE` (default: local)