n8n in queue mode with Redis, PostgreSQL persistence, and proper process supervision — the boring, reliable setup that survives restarts and workload spikes. The automation layer behind several of my
A complete Kubernetes lab-to-production pattern: k3s in Docker with the embedded etcd datastore, Rancher for management, MetalLB for Layer-2 LoadBalancer IPs, Longhorn replicated storage, and Traefik
Dify — visual LLM app builder with RAG, agents, and prompt workflows — backed by PostgreSQL, Redis, Weaviate, an SSRF proxy and a code sandbox. The deployment pattern I use for LLM applications that non-developers build on.
A deployment guide with working examples — not a downloadable product. Everything below is the actual configuration I use, abridged to the parts that matter.
services:
api:
image: langgenius/dify-api:${DIFY_VERSION:-latest}
container_name: dify-api
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_started
weaviate:
condition: service_healthy
volumes:
- dify_storage_data:/app/api/storage
ports:
- ${DIFY_API_PORT:-5001}:5001
environment:
- MODE=api
- SECRET_KEY=${DIFY_SECRET_KEY:?DIFY_SECRET_KEY is required}
- INIT_PASSWORD=${DIFY_INIT_PASSWORD:-}
- LOG_LEVEL=${LOG_LEVEL:-INFO}
- DB_USERNAME=${POSTGRES_USER:-dify}
- DB_PASSWORD=${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
- DB_HOST=postgres
- DB_PORT=5432
- DB_DATABASE=${POSTGRES_DB:-dify}
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD:?REDIS_PASSWORD is required}
- REDIS_DB=0
- WEAVIATE_HOST=weaviate
- WEAVIATE_PORT=8080
- WEAVIATE_API_KEY=${WEAVIATE_API_KEY:?WEAVIATE_API_KEY is required}
- WEAVIATE_BATCH_SIZE=100
- STORAGE_TYPE=${STORAGE_TYPE:-local}
- STORAGE_LOCAL_PATH=storage
- CELERY_BROKER_URL=redis://:${REDIS_PASSWORD:?REDIS_PASSWORD is required}@redis:6379/1
- SENTRY_DSN=
- CONSOLE_API_URL=${CONSOLE_API_URL:-http://localhost:5001}
- APP_API_URL=${APP_API_URL:-http://localhost:5001}
- SSRF_PROXY_URL=http://ssrf_proxy:3128
healthcheck:
test:
- CMD
- curl
- -f
- http://localhost:5001/health
interval: 30s
timeout: 10s
retries: 3
networks:
- dify_network
worker:
image: langgenius/dify-api:${DIFY_VERSION:-latest}
container_name: dify-worker
restart: unless-stopped
depends_on:
api:
condition: service_healthy
volumes:
- dify_storage_data:/app/api/storage
environment:
- MODE=worker
- SECRET_KEY=${DIFY_SECRET_KEY:?DIFY_SECRET_KEY is required}
- LOG_LEVEL=${LOG_LEVEL:-INFO}
- DB_USERNAME=${POSTGRES_USER:-dify}
- DB_PASSWORD=${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
- DB_HOST=postgres
- DB_PORT=5432
- DB_DATABASE=${POSTGRES_DB:-dify}
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD:?REDIS_PASSWORD is required}
- REDIS_DB=0
- WEAVIATE_HOST=weaviate
- WEAVIATE_PORT=8080
- WEAVIATE_API_KEY=${WEAVIATE_API_KEY:?WEAVIATE_API_KEY is required}
- CELERY_BROKER_URL=redis://:${REDIS_PASSWORD:?REDIS_PASSWORD is required}@redis:6379/1
- CELERY_WORKER_CONCURRENCY=${CELERY_WORKER_CONCURRENCY:-4}
- CELERY_WORKER_MAX_TASKS_PER_CHILD=${CELERY_WORKER_MAX_TASKS_PER_CHILD:-100}
- SENTRY_DSN=
- CONSOLE_API_URL=${CONSOLE_API_URL:-http://localhost:5001}
- APP_API_URL=${APP_API_URL:-http://localhost:5001}
- SSRF_PROXY_URL=http://ssrf_proxy:3128
healthcheck:
test:
- CMD-SHELL
- celery -p app.celery.app inspect ping -d celery@$$HOSTNAME || exit 1
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
networks:
- dify_network
Excerpt — api, worker from the compose file. The remaining services (proxies, init jobs, exporters) follow the same pattern and mount their configuration from a config/ directory.
Copy .env.example to .env and at minimum set:
POSTGRES_PASSWORD=<generate-strong-password>
REDIS_PASSWORD=<generate-strong-password>
WEAVIATE_API_KEY=<generate-api-key>
DIFY_SECRET_KEY=<generate-64-char-string>
DIFY_INIT_PASSWORD=
POSTGRES_USER=dify
POSTGRES_PASSWORD, REDIS_PASSWORD, WEAVIATE_API_KEY, DIFY_SECRET_KEYCONSOLE_API_URL and APP_API_URL with your domainDIFY_INIT_PASSWORD for first-time admin setupDIFY_VERSION=1.2.0)STORAGE_TYPE=s3) for multi-server setupshttp://localhost:5001/healthA guide, not a product. This page is deployment documentation with working examples — there is no zip, no download, no support contract. You adapt the patterns to your own environment, and you own the result.
Want this running production-grade in your infrastructure instead? I run this as part of the Self-Hosted AI in Production workshop — details on the consulting page: €1,000/day, remote or on-site, invoice as usual.