Deployment
Bub works interactively in your local terminal (see Terminal interaction), and you can also deploy it to a server as a long-running service:
- Persistent message gateway: listen on Telegram, Feishu, or Discord 24/7 and reply to messages.
- Containerized sandbox: run development toolchains inside an isolated container and attach via
bub chatwithout exposing the host filesystem.
Comparison of the two deployment modes:
| Mode | Best for | Key benefits |
|---|---|---|
| Docker Compose (recommended) | Cloud VMs, VPS, NAS, local containers | Bundles Python, uv, Git, Node.js, and pnpm; isolates the host; easy to back up and upgrade |
| System daemon | Linux / Windows hosts with an existing Python environment | Low overhead; registers as a user service in one command via bub gateway --install |
Before you start
Section titled “Before you start”- Model credentials: set
BUB_MODELandBUB_API_KEYin.env(see Configuration). - Channel allowlists: always configure an allowlist (such as
BUB_TELEGRAM_ALLOW_USERS) so unauthorized users cannot invoke your agent. - Persistent data volume: mount the data directory (host
~/.bub, container/data) to preserve session Tapes and managed plugins across restarts.
Docker Compose deployment
Section titled “Docker Compose deployment”The official image (ghcr.io/bubbuild/bub) comes preinstalled with Python 3.12, uv, Git, Node.js, and pnpm.
1. Prepare configuration
Section titled “1. Prepare configuration”Download docker-compose.yml and env.example:
mkdir -p bub-deploy && cd bub-deploycurl -O https://raw.githubusercontent.com/bubbuild/bub/main/docker-compose.ymlcurl -O https://raw.githubusercontent.com/bubbuild/bub/main/env.examplecp env.example .envEdit .env:
# ModelBUB_MODEL=openrouter:openrouter/freeBUB_API_KEY=sk-or-...
# Channel (Telegram example)BUB_TELEGRAM_TOKEN=123456789:your-telegram-bot-tokenBUB_TELEGRAM_ALLOW_USERS=123456789,your_telegram_username
# Optional host paths# BUB_HOME_HOST=~/.bub# BUB_WORKSPACE_PATH=.2. Review volume mounts
Section titled “2. Review volume mounts”docker-compose.yml mounts three directories by default:
volumes: - ${BUB_WORKSPACE_PATH:-.}:/workspace - ${BUB_HOME_HOST:-${HOME}/.bub}:/data - ${BUB_AGENT_HOME:-${HOME}/.agents}:/root/.agents| Container path | Host path | Purpose |
|---|---|---|
/workspace |
BUB_WORKSPACE_PATH (default .) |
Workspace: directory where the Agent reads/writes files and runs commands |
/data |
BUB_HOME_HOST (default ~/.bub) |
Data directory (BUB_HOME=/data): stores session Tapes and managed plugins |
/root/.agents |
BUB_AGENT_HOME (default ~/.agents) |
Global skills: shared skills across workspaces |
3. Start the container
Section titled “3. Start the container”docker compose pulldocker compose up -ddocker compose logs -f appIn production, pin a specific version tag in .env (e.g. BUB_IMAGE=ghcr.io/bubbuild/bub:0.6.0).
docker compose up -d --builddocker run -d --name bub --restart unless-stopped \ --env-file .env \ -e BUB_HOME=/data \ -v "$PWD":/workspace \ -v "$HOME/.bub":/data \ -v "$HOME/.agents":/root/.agents \ ghcr.io/bubbuild/bub:latest
docker logs -f bub4. Verify startup
Section titled “4. Verify startup”docker compose psdocker compose logs -f appWhen the Telegram gateway is ready, it logs:
telegram.start allow_users_count=1 allow_chats_count=0 proxy_enabled=Falsetelegram.start polling5. Attach an interactive chat
Section titled “5. Attach an interactive chat”Compose enables stdin_open and tty by default. Even while the container runs the gateway in the background, you can attach at any time for an interactive bub chat session:
docker compose exec -it app bub chatThis lets you pair-program directly with the Agent inside an isolated cloud sandbox with the preinstalled toolchain.
6. Customize startup and dependencies
Section titled “6. Customize startup and dependencies”At container startup, entrypoint.sh runs three steps:
- If
/workspace/bub-reqs.txtexists, installs extra Python packages viauv pip install. - Activates the virtual environment and runs
bub installto sync managed plugins in/data/bub-project. - Executes
/workspace/startup.shif present; otherwise runsbub gateway.
To customize the startup command, create an executable /workspace/startup.sh (use exec so shutdown signals reach the gateway):
#!/bin/bashset -euo pipefailexec /app/.venv/bin/bub gateway --enable-channel telegram7. Manage plugins inside the container
Section titled “7. Manage plugins inside the container”Managed plugins live on the /data/bub-project volume and can be installed or updated without rebuilding the image:
docker compose exec app bub install https://github.com/owner/repo.git@v1.2.0docker compose exec app bub updatedocker compose restart app8. Back up and upgrade
Section titled “8. Back up and upgrade”Stop the container and back up the data directory before upgrading:
docker compose stop apptar -czf "bub-data-$(date +%Y%m%d-%H%M%S).tar.gz" "$HOME/.bub"cp .env ".env.bak-$(date +%Y%m%d-%H%M%S)"
docker compose pulldocker compose up -dTo roll back, switch BUB_IMAGE back to the previous tag in .env (for example BUB_IMAGE=ghcr.io/bubbuild/bub:0.6.0) and restart.
System daemon mode
Section titled “System daemon mode”On a Linux or Windows host with Python installed, you can register the gateway as a background user service with bub gateway --install:
- Linux: registers as a systemd user service at
~/.config/systemd/user/bub-gateway.service. - Windows: registers as a scheduled task for the current user (starts at login and restarts on failure).
- macOS:
--installis not supported yet; uselaunchd,tmux, or the Docker approach above.
1. Install the service
Section titled “1. Install the service”Run in the workspace directory containing .env:
uv venv && source .venv/bin/activateuv pip install 'bub[app]'bub gateway --installThe installer automatically records the current Python interpreter path, workspace directory, and environment variables.
2. Manage the service (Linux)
Section titled “2. Manage the service (Linux)”After you log out of SSH on Linux, user-level services stop by default. Enable linger to keep the gateway running 24/7:
loginctl enable-linger $USERCommon systemctl commands:
systemctl --user status bub-gatewayjournalctl --user -u bub-gateway -fsystemctl --user restart bub-gatewaysystemctl --user stop bub-gateway3. Uninstall the service
Section titled “3. Uninstall the service”To remove the background service, run:
bub gateway --uninstallSecurity checklist
Section titled “Security checklist”- Configure allowlists: set
BUB_TELEGRAM_ALLOW_USERSorBUB_TELEGRAM_ALLOW_CHATS. - Scope the workspace: mount only the target project directory, never host credentials or system paths.
- Set a step limit: configure
BUB_MAX_STEPS(unlimited by default; set to e.g.50in production) to prevent runaway loops. - Protect secrets: pass API keys via
.envor environment variables and keep them out of version control. - Back up Tapes regularly: archive
~/.bub(or container/data) periodically.