|
| 1 | +# Deployment |
| 2 | + |
| 3 | +Hive ships a `Dockerfile` and `docker-compose.yml` that run the REST API and the |
| 4 | +heartbeat daemon together in one container -- the agent OS in your own infrastructure. |
| 5 | + |
| 6 | +## Docker Compose (one command) |
| 7 | + |
| 8 | +```bash |
| 9 | +ANTHROPIC_API_KEY=sk-... docker compose up --build |
| 10 | +``` |
| 11 | + |
| 12 | +- Control plane: <http://localhost:8000/> |
| 13 | +- API docs: <http://localhost:8000/docs> |
| 14 | + |
| 15 | +Provider keys are read from your shell (or a `.env` file) and passed through; set only |
| 16 | +the ones you use (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GROQ_API_KEY`, |
| 17 | +`HIVE_DEFAULT_MODEL`). Agent state, logs, and workspaces persist in the `hive_state` |
| 18 | +volume across restarts. |
| 19 | + |
| 20 | +## Plain Docker |
| 21 | + |
| 22 | +```bash |
| 23 | +docker build -t hive-agentos . |
| 24 | +docker run -p 8000:8000 \ |
| 25 | + -e ANTHROPIC_API_KEY=sk-... \ |
| 26 | + -v hive_state:/data \ |
| 27 | + hive-agentos |
| 28 | +``` |
| 29 | + |
| 30 | +## How the image is built |
| 31 | + |
| 32 | +- **Multi-stage**: a build stage installs the package (with the `[api]` extra) into a |
| 33 | + self-contained venv via `uv sync --no-editable`; the slim runtime stage copies only |
| 34 | + that venv. |
| 35 | +- Runs as a **non-root** user; all writable state lives under `/data` (the working |
| 36 | + directory and the mount point), so the container filesystem stays read-only-friendly. |
| 37 | +- The entrypoint runs the idempotent `hive init` then |
| 38 | + `hive serve --host 0.0.0.0 --port 8000 --with-daemon`, so a single process serves |
| 39 | + HTTP and drives agents. |
| 40 | + |
| 41 | +## Scaling notes |
| 42 | + |
| 43 | +`hive serve` (without `--with-daemon`) is **stateless** and can run behind a load |
| 44 | +balancer with several replicas, all reading/writing one shared `.hive/hive.db` (SQLite |
| 45 | +WAL handles concurrent access). Run **one** `--with-daemon` instance (or a standalone |
| 46 | +`hive start`) to drive the heartbeat, and scale the API replicas separately. For |
| 47 | +heavier multi-writer loads, point the daemon and API at shared storage for `/data`. |
| 48 | + |
| 49 | +## Production checklist |
| 50 | + |
| 51 | +- Set real provider API keys via secrets, not in the image. |
| 52 | +- Put the API behind TLS and authentication (the server binds `0.0.0.0` in the |
| 53 | + container; restrict exposure at the proxy/ingress). |
| 54 | +- Back up the `/data` volume (it holds the SQLite DB, event logs, and workspaces). |
| 55 | +- Tune `.hive/config.yaml` (`daemon.heartbeat`, `daemon.max_concurrent_agents`) for |
| 56 | + your workload; enable `approval` and `guardrails` for untrusted use. |
0 commit comments