ai-stack/README.md
Turnkey Local AI Automation: n8n + Agent Zero + ComfyUI
A single-command deployable stack for AI-powered workflow automation with image generation capabilities.
š START HERE: Documentation Index - Choose the right guide for you!
| Service | Purpose | Port | URL |
|---|---|---|---|
| n8n | Workflow automation engine (the conductor) | 5678 | http://localhost:5678 |
| Agent Zero | AI agent runtime & planning UI | 50080 | http://localhost:50080 |
| ComfyUI | AI image/video generation | 8188 | http://localhost:8188 |
Windows (PowerShell):
.\start.ps1
Linux/macOS:
chmod +x start.sh
./start.sh
That's it! The script will:
ai-stack/
āāā docker-compose.yml # Main stack configuration
āāā .env # Environment variables
āāā start.ps1 # Windows startup script
āāā start.sh # Linux/macOS startup script
āāā README.md # This file
ā
āāā data/ # Persistent data (auto-created)
ā āāā n8n/ # n8n workflows & credentials
ā āāā agent-zero/ # Agent Zero data
ā
āāā shared/ # Shared between all services
ā āāā comfyui/
ā ā āāā models/ # AI models (checkpoints, LoRAs, etc.)
ā ā ā āāā checkpoints/
ā ā ā āāā loras/
ā ā ā āāā vae/
ā ā ā āāā controlnet/
ā ā ā āāā embeddings/
ā ā āāā output/ # Generated images
ā ā āāā input/ # Input images
ā ā āāā custom_nodes/ # ComfyUI extensions
ā āāā workflows/ # Shared workflow files
ā
āāā workflows/ # Pre-built n8n workflows
āāā comfyui-image-generation.json
āāā comfyui-simple-test.json
.\start.ps1 # Start the stack
.\start.ps1 -Stop # Stop the stack
.\start.ps1 -Logs # View logs
.\start.ps1 -Status # Check status
.\start.ps1 -NoPull # Start without pulling images
.\start.ps1 -CPU # Force CPU mode (no GPU)
./start.sh # Start the stack
./start.sh --stop # Stop the stack
./start.sh --logs # View logs
./start.sh --status # Check status
./start.sh --no-pull # Start without pulling images
./start.sh --cpu # Force CPU mode (no GPU)
docker compose up -d # Start
docker compose down # Stop
docker compose logs -f # View logs
docker compose ps # Status
Place your models in the appropriate directories:
| Model Type | Directory |
|---|---|
| Stable Diffusion checkpoints | shared/comfyui/models/checkpoints/ |
| LoRA models | shared/comfyui/models/loras/ |
| VAE models | shared/comfyui/models/vae/ |
| ControlNet models | shared/comfyui/models/controlnet/ |
| Upscale models | shared/comfyui/models/upscale_models/ |
| Embeddings | shared/comfyui/models/embeddings/ |
Download SD 1.5 and place it in shared/comfyui/models/checkpoints/.
File: workflows/comfyui-image-generation.json
A complete webhook-triggered image generation pipeline:
curl -X POST http://localhost:5678/webhook/generate-image \
-H "Content-Type: application/json" \
-d '{
"prompt": "a cyberpunk city at night, neon lights, rain, highly detailed",
"negative_prompt": "blurry, low quality",
"steps": 20,
"cfg": 7,
"width": 512,
"height": 512
}'
File: workflows/comfyui-simple-test.json
A simple connectivity test:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā n8n (Conductor) ā
ā http://localhost:5678 ā
āāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāā
ā ā
ā¼ ā¼
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Agent Zero ā ā ComfyUI ā
ā http://localhost:50080 ā ā http://localhost:8188 ā
ā ā ā ā
ā ⢠AI planning/reasoning ā ā ⢠POST /prompt (queue job) ā
ā ⢠Tool use decisions ā ā ⢠GET /history/{id} (results) ā
ā ⢠Prompt optimization ā ā ⢠GET /view (retrieve images) ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā
āāāāāāāāāāāāā¬āāāāāāāāāāāā
ā¼
āāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Shared Volume ā
ā ./shared/ ā
ā ā
ā ⢠ComfyUI outputs ā
ā ⢠Shared workflows ā
ā ⢠Cross-service data ā
āāāāāāāāāāāāāāāāāāāāāāāāāāā
POST /promptGET /history/{prompt_id} until completePOST http://comfyui:8188/prompt
Content-Type: application/json
{
"prompt": { /* ComfyUI workflow JSON */ }
}
Response:
{
"prompt_id": "abc123-def456-..."
}
GET http://comfyui:8188/history/{prompt_id}
GET http://comfyui:8188/queue
GET http://comfyui:8188/view?filename={name}&subfolder=&type=output
GET http://comfyui:8188/system_stats
# Timezone
TZ=America/Los_Angeles
# n8n Basic Auth (optional)
N8N_BASIC_AUTH_ACTIVE=false
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=changeme
# API Keys for Agent Zero (optional)
OPENAI_API_KEY=sk-your-key-here
ANTHROPIC_API_KEY=sk-ant-your-key-here
If running behind a reverse proxy:
WEBHOOK_URL=https://your-domain.com
.env file (not committed to git)docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi to test# Check logs
docker compose logs -f
# Restart specific service
docker compose restart n8n
# Full reset
docker compose down -v
docker compose up -d
http://comfyui:8188 (Docker internal network), not localhostdocker compose psEdit docker-compose.yml to change port mappings:
ports:
- "NEW_PORT:INTERNAL_PORT"
MIT License - Use freely for personal and commercial projects.