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
117 lines
3.8 KiB
Markdown
117 lines
3.8 KiB
Markdown
# Multi-Bot Docker Setup Summary
|
|
|
|
## ✅ Setup Complete
|
|
|
|
### Files Created
|
|
|
|
1. **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)
|
|
|
|
2. **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)
|
|
|
|
3. **Docker Compose:**
|
|
- `docker-compose.multi.env.yml` - Multi-bot Docker Compose configuration
|
|
|
|
## 🔍 How It Works
|
|
|
|
### Configuration Loading Order
|
|
|
|
1. **Docker Compose loads environment files:**
|
|
- First: `.env.shared` (shared settings)
|
|
- Second: `.env.user1` (bot-specific overrides)
|
|
- Later files override earlier ones ✅
|
|
|
|
2. **Container starts with volume mount:**
|
|
- Host: `~/.nanobot-user1`
|
|
- Container: `/root/.nanobot`
|
|
- This maps your config directory into the container ✅
|
|
|
|
3. **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`)
|
|
|
|
- **Config file**: Loaded from `/root/.nanobot/config.json`
|
|
- Inside container: `/root/.nanobot/config.json`
|
|
- On host: `~/.nanobot-user1/config.json` (mounted)
|
|
- Contains: `allowFrom` arrays (can't be in env vars)
|
|
|
|
### 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
|
|
|
|
```bash
|
|
# 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
|
|
|
|
- [x] `.env.shared` created with shared settings
|
|
- [x] `.env.user1` created with bot-specific settings
|
|
- [x] `ALLOW_FROM` removed from env files (arrays belong in config.json)
|
|
- [x] Config directories created (`~/.nanobot-user1`, etc.)
|
|
- [x] Config files created with `allowFrom` arrays
|
|
- [x] Docker Compose file configured correctly
|
|
- [x] Volume mounts map host configs to container paths
|
|
|
|
## 🎯 Key Points
|
|
|
|
1. **Environment Variables** → For simple key-value settings (tokens, API keys, models)
|
|
2. **Config Files** → For complex settings (arrays like `allowFrom`)
|
|
3. **Docker Mounts** → Each container gets its own config directory
|
|
4. **Original Config** → Not used by Docker containers (stays safe)
|
|
|
|
## 📝 Next Steps
|
|
|
|
1. Update `.env.user2` and `.env.user3` with bot-specific settings
|
|
2. Update `~/.nanobot-user2/config.json` and `~/.nanobot-user3/config.json` with actual user IDs/emails
|
|
3. Run `docker compose -f docker-compose.multi.env.yml up -d` to start all bots
|
|
4. Check logs to verify each bot is using correct configuration
|
|
|
|
|