Document and add multi-bot Docker workflows with env layering scripts, and update agent/tool configuration handling to make MCP/email/calendar behavior more robust for day-to-day operations. Made-with: Cursor
3.8 KiB
3.8 KiB
Multi-Bot Docker Setup Summary
✅ Setup Complete
Files Created
-
Environment Files:
.env.shared- Shared settings (providers, agents, tools, gateway).env.user1- Bot 1 specific settings (Telegram token, email credentials).env.user2- Bot 2 specific settings (placeholder).env.user3- Bot 3 specific settings (placeholder)
-
Config Files:
~/.nanobot-user1/config.json- Bot 1 channel config (allowFrom arrays)~/.nanobot-user2/config.json- Bot 2 channel config (placeholder)~/.nanobot-user3/config.json- Bot 3 channel config (placeholder)
-
Docker Compose:
docker-compose.multi.env.yml- Multi-bot Docker Compose configuration
🔍 How It Works
Configuration Loading Order
-
Docker Compose loads environment files:
- First:
.env.shared(shared settings) - Second:
.env.user1(bot-specific overrides) - Later files override earlier ones ✅
- First:
-
Container starts with volume mount:
- Host:
~/.nanobot-user1 - Container:
/root/.nanobot - This maps your config directory into the container ✅
- Host:
-
Nanobot loads configuration:
-
Environment variables: Automatically loaded by Pydantic
BaseSettings- Format:
NANOBOT_CHANNELS__TELEGRAM__TOKEN=... - These come from Docker environment (loaded from
.env.shared+.env.user1)
- Format:
-
Config file: Loaded from
/root/.nanobot/config.json- Inside container:
/root/.nanobot/config.json - On host:
~/.nanobot-user1/config.json(mounted) - Contains:
allowFromarrays (can't be in env vars)
- Inside container:
-
Important: Original Config is NOT Used
Your original config (~/.nanobot/config.json) is NOT used by Docker containers.
Each container uses:
- Its own env files (
.env.shared+.env.userX) - Its own config directory (
~/.nanobot-userX)
This means:
- ✅ Original config stays untouched
- ✅ Each bot has isolated configuration
- ✅ No conflicts between bots
📋 Current Configuration
Bot 1 (nanobot-user1)
Environment Variables (from .env.shared + .env.user1):
- Provider: Custom/Ollama (
http://localhost:11434/v1) - Model:
llama3.1:8b - Workspace:
/mnt/data/nanobot - Telegram: Enabled with token
- Email: Enabled with credentials
Config File (~/.nanobot-user1/config.json):
- Telegram
allowFrom:["TADec2023"] - Email
allowFrom:["adayear2025@gmail.com"]
🚀 Running the Bots
# Build Docker image (first time)
docker compose -f docker-compose.multi.env.yml build
# Start all bots
docker compose -f docker-compose.multi.env.yml up -d
# View logs
docker compose -f docker-compose.multi.env.yml logs -f
# Stop all bots
docker compose -f docker-compose.multi.env.yml down
# Restart specific bot
docker restart nanobot-user1
✅ Verification Checklist
.env.sharedcreated with shared settings.env.user1created with bot-specific settingsALLOW_FROMremoved from env files (arrays belong in config.json)- Config directories created (
~/.nanobot-user1, etc.) - Config files created with
allowFromarrays - Docker Compose file configured correctly
- Volume mounts map host configs to container paths
🎯 Key Points
- Environment Variables → For simple key-value settings (tokens, API keys, models)
- Config Files → For complex settings (arrays like
allowFrom) - Docker Mounts → Each container gets its own config directory
- Original Config → Not used by Docker containers (stays safe)
📝 Next Steps
- Update
.env.user2and.env.user3with bot-specific settings - Update
~/.nanobot-user2/config.jsonand~/.nanobot-user3/config.jsonwith actual user IDs/emails - Run
docker compose -f docker-compose.multi.env.yml up -dto start all bots - Check logs to verify each bot is using correct configuration