# Developing Nanobot with Docker

## Current Setup (Production)

**`docker-compose.multi.env.yml`** - Production mode:
- Code is **copied** into Docker image during build
- Changes to source code **NOT** picked up automatically
- Need to rebuild image: `docker compose -f docker-compose.multi.env.yml build`

## Development Setup

**`docker-compose.multi.dev.yml`** - Development mode:
- Source code is **mounted** as volume
- Changes to `nanobot/` directory **picked up automatically**
- Just restart container (no rebuild needed)

## How It Works

### Production Mode (Current)
```bash
# 1. Build image (copies code)
docker compose -f docker-compose.multi.env.yml build

# 2. Run container
docker compose -f docker-compose.multi.env.yml up -d

# 3. Make code changes...
# 4. Changes NOT visible - need to rebuild:
docker compose -f docker-compose.multi.env.yml build
docker compose -f docker-compose.multi.env.yml up -d --force-recreate
```

### Development Mode (Recommended for Development)
```bash
# 1. Build image once (for dependencies)
docker compose -f docker-compose.multi.dev.yml build

# 2. Run container
docker compose -f docker-compose.multi.dev.yml up -d

# 3. Make code changes in venv...
# 4. Changes visible immediately - just restart:
docker compose -f docker-compose.multi.dev.yml restart nanobot-user1
```

## Workflow

### Option 1: Develop in Venv, Test in Docker (Recommended)

```bash
# Terminal 1: Develop in venv
source venv/bin/activate
# Edit code, test locally if needed
nano nanobot/channels/telegram.py

# Terminal 2: Run Docker in dev mode
docker compose -f docker-compose.multi.dev.yml up -d nanobot-user1

# After making changes, restart container:
docker compose -f docker-compose.multi.dev.yml restart nanobot-user1

# Watch logs:
docker logs -f nanobot-user1-dev
```

### Option 2: Rebuild After Changes (Current)

```bash
# Make changes in venv
source venv/bin/activate
nano nanobot/channels/telegram.py

# Rebuild Docker image
docker compose -f docker-compose.multi.env.yml build nanobot-user1

# Recreate container
docker compose -f docker-compose.multi.env.yml up -d --force-recreate nanobot-user1
```

## Important Notes

### Development Mode (`docker-compose.multi.dev.yml`)
- ✅ Changes picked up automatically
- ✅ Faster iteration (no rebuild needed)
- ⚠️ Mounts source code (may have slight performance impact)
- ⚠️ Python needs to reload modules (restart container)

### Production Mode (`docker-compose.multi.env.yml`)
- ✅ Code baked into image (more stable)
- ✅ No performance impact from mounts
- ❌ Need rebuild for every change
- ✅ Better for production deployments

## Quick Reference

```bash
# Development workflow
docker compose -f docker-compose.multi.dev.yml up -d nanobot-user1
# ... make changes ...
docker compose -f docker-compose.multi.dev.yml restart nanobot-user1

# Production workflow  
docker compose -f docker-compose.multi.env.yml build nanobot-user1
docker compose -f docker-compose.multi.env.yml up -d --force-recreate nanobot-user1
```

## Which Should You Use?

- **Developing code**: Use `docker-compose.multi.dev.yml`
- **Production/staging**: Use `docker-compose.multi.env.yml`
- **Quick testing**: Use venv directly on host


