Skip to content

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 chat without 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
  1. Model credentials: set BUB_MODEL and BUB_API_KEY in .env (see Configuration).
  2. Channel allowlists: always configure an allowlist (such as BUB_TELEGRAM_ALLOW_USERS) so unauthorized users cannot invoke your agent.
  3. Persistent data volume: mount the data directory (host ~/.bub, container /data) to preserve session Tapes and managed plugins across restarts.

The official image (ghcr.io/bubbuild/bub) comes preinstalled with Python 3.12, uv, Git, Node.js, and pnpm.

Download docker-compose.yml and env.example:

Terminal window
mkdir -p bub-deploy && cd bub-deploy
curl -O https://raw.githubusercontent.com/bubbuild/bub/main/docker-compose.yml
curl -O https://raw.githubusercontent.com/bubbuild/bub/main/env.example
cp env.example .env

Edit .env:

.env
# Model
BUB_MODEL=openrouter:openrouter/free
BUB_API_KEY=sk-or-...
# Channel (Telegram example)
BUB_TELEGRAM_TOKEN=123456789:your-telegram-bot-token
BUB_TELEGRAM_ALLOW_USERS=123456789,your_telegram_username
# Optional host paths
# BUB_HOME_HOST=~/.bub
# BUB_WORKSPACE_PATH=.

docker-compose.yml mounts three directories by default:

docker-compose.yml
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
Terminal window
docker compose pull
docker compose up -d
docker compose logs -f app

In production, pin a specific version tag in .env (e.g. BUB_IMAGE=ghcr.io/bubbuild/bub:0.6.0).

Terminal window
docker compose ps
docker compose logs -f app

When the Telegram gateway is ready, it logs:

telegram.start allow_users_count=1 allow_chats_count=0 proxy_enabled=False
telegram.start polling

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:

Terminal window
docker compose exec -it app bub chat

This lets you pair-program directly with the Agent inside an isolated cloud sandbox with the preinstalled toolchain.

At container startup, entrypoint.sh runs three steps:

  1. If /workspace/bub-reqs.txt exists, installs extra Python packages via uv pip install.
  2. Activates the virtual environment and runs bub install to sync managed plugins in /data/bub-project.
  3. Executes /workspace/startup.sh if present; otherwise runs bub gateway.

To customize the startup command, create an executable /workspace/startup.sh (use exec so shutdown signals reach the gateway):

/workspace/startup.sh
#!/bin/bash
set -euo pipefail
exec /app/.venv/bin/bub gateway --enable-channel telegram

Managed plugins live on the /data/bub-project volume and can be installed or updated without rebuilding the image:

Terminal window
docker compose exec app bub install https://github.com/owner/repo.git@v1.2.0
docker compose exec app bub update
docker compose restart app

Stop the container and back up the data directory before upgrading:

Terminal window
docker compose stop app
tar -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 pull
docker compose up -d

To 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.


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: --install is not supported yet; use launchd, tmux, or the Docker approach above.

Run in the workspace directory containing .env:

Terminal window
uv venv && source .venv/bin/activate
uv pip install 'bub[app]'
bub gateway --install

The installer automatically records the current Python interpreter path, workspace directory, and environment variables.

After you log out of SSH on Linux, user-level services stop by default. Enable linger to keep the gateway running 24/7:

Terminal window
loginctl enable-linger $USER

Common systemctl commands:

Terminal window
systemctl --user status bub-gateway
journalctl --user -u bub-gateway -f
systemctl --user restart bub-gateway
systemctl --user stop bub-gateway

To remove the background service, run:

Terminal window
bub gateway --uninstall

  • Configure allowlists: set BUB_TELEGRAM_ALLOW_USERS or BUB_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. 50 in production) to prevent runaway loops.
  • Protect secrets: pass API keys via .env or environment variables and keep them out of version control.
  • Back up Tapes regularly: archive ~/.bub (or container /data) periodically.