diff --git a/CLAUDE.md b/CLAUDE.md index 65c025d..8cba1d4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,19 +10,23 @@ ``` compose_farm/ -├── config.py # Pydantic models, YAML loading -├── ssh.py # asyncssh execution, streaming -└── cli.py # Typer commands +├── cli.py # Typer commands (cf/compose-farm CLI) +├── config.py # Pydantic models, YAML loading +├── ssh.py # asyncssh execution, streaming, local detection +├── state.py # Deployment state tracking (which service on which host) +├── logs.py # Image digest snapshots (dockerfarm-log.toml) +└── traefik.py # Traefik file-provider config generation from labels ``` ## Key Design Decisions 1. **asyncssh over Paramiko/Fabric**: Native async support, built-in streaming 2. **Parallel by default**: Multiple services run concurrently via `asyncio.gather` -3. **Streaming output**: Real-time stdout/stderr with `[service]` prefix +3. **Streaming output**: Real-time stdout/stderr with `[service]` prefix using Rich 4. **SSH key auth only**: Uses ssh-agent, no password handling (YAGNI) 5. **NFS assumption**: Compose files at same path on all hosts -6. **Local execution**: When host is `localhost`/`local`, skip SSH and run locally +6. **Local IP auto-detection**: Skips SSH when target host matches local machine's IP +7. **State tracking**: Tracks where services are deployed for auto-migration ## Communication Notes @@ -36,12 +40,17 @@ compose_farm/ ## Commands Quick Reference -| Command | Docker Compose Equivalent | -|---------|--------------------------| -| `up` | `docker compose up -d` | -| `down` | `docker compose down` | -| `pull` | `docker compose pull` | -| `restart` | `down` + `up -d` | +CLI available as `cf` or `compose-farm`. + +| Command | Description | +|---------|-------------| +| `up` | Start services (`docker compose up -d`), auto-migrates if host changed | +| `down` | Stop services (`docker compose down`) | +| `pull` | Pull latest images | +| `restart` | `down` + `up -d` | | `update` | `pull` + `down` + `up -d` | -| `logs` | `docker compose logs` | -| `ps` | `docker compose ps` | +| `logs` | Show service logs | +| `ps` | Show status of all services | +| `sync` | Discover running services, update state, capture image digests | +| `check` | Validate config vs disk, check traefik labels have ports | +| `traefik-file` | Generate Traefik file-provider config from compose labels |