GCP Compute Engine (Docker)
Scope
This is a production-style setup for running the Moltbot Gateway 24/7 on Google Cloud:
- Docker runtime (repeatable rebuilds)
- Persistent state on the host (
~/.moltbotand~/clawd) - Loopback-only bind on the VM; access from your laptop via SSH tunnel
Prerequisites
- A GCP account with billing enabled
- A Compute Engine VM (Debian 12 or Ubuntu)
- Docker + Compose on the VM
- Model/channel credentials ready (API keys, OAuth, bot tokens, etc.)
Setup (operator runbook)
1) Create the VM
Pick a small VM to start (e.g. e2-small). Ensure you can SSH in.
2) Install Docker (on the VM)
sudo apt-get update
sudo apt-get install -y git curl ca-certificates
curl -fsSL https://get.docker.com | sudo sh
sudo usermod -aG docker "$USER"
exitSSH back in and verify:
docker --version
docker compose version3) Clone the repo and create persistent directories
git clone https://github.com/moltbot/moltbot.git
cd moltbot
mkdir -p ~/.moltbot
mkdir -p ~/clawd4) Create .env (do not commit)
cat > .env <<'EOF'
MOLTBOT_IMAGE=moltbot:latest
MOLTBOT_GATEWAY_TOKEN=change-me-now
MOLTBOT_GATEWAY_BIND=lan
MOLTBOT_GATEWAY_PORT=18789
MOLTBOT_CONFIG_DIR=/home/$USER/.moltbot
MOLTBOT_WORKSPACE_DIR=/home/$USER/clawd
GOG_KEYRING_PASSWORD=change-me-now
XDG_CONFIG_HOME=/home/node/.moltbot
EOFGenerate strong secrets:
openssl rand -hex 325) Create docker-compose.yml
This keeps the Gateway loopback-only on the VM and mounts durable state from the host:
services:
moltbot-gateway:
image: ${MOLTBOT_IMAGE}
build: .
restart: unless-stopped
env_file:
- .env
environment:
- HOME=/home/node
- NODE_ENV=production
- TERM=xterm-256color
- MOLTBOT_GATEWAY_BIND=${MOLTBOT_GATEWAY_BIND}
- MOLTBOT_GATEWAY_PORT=${MOLTBOT_GATEWAY_PORT}
- MOLTBOT_GATEWAY_TOKEN=${MOLTBOT_GATEWAY_TOKEN}
- GOG_KEYRING_PASSWORD=${GOG_KEYRING_PASSWORD}
- XDG_CONFIG_HOME=${XDG_CONFIG_HOME}
volumes:
- ${MOLTBOT_CONFIG_DIR}:/home/node/.moltbot
- ${MOLTBOT_WORKSPACE_DIR}:/home/node/clawd
ports:
- "127.0.0.1:${MOLTBOT_GATEWAY_PORT}:18789"
command:
[
"node",
"dist/index.js",
"gateway",
"--bind",
"${MOLTBOT_GATEWAY_BIND}",
"--port",
"${MOLTBOT_GATEWAY_PORT}"
]6) Bake required binaries into the image (important)
If any of your skills depend on external binaries, install them in the Dockerfile at build time (not inside a running container).
7) Build and start
docker compose build
docker compose up -d moltbot-gateway
docker compose logs -f moltbot-gateway8) Access from your laptop (SSH tunnel)
gcloud compute ssh moltbot-gateway --zone=us-central1-a -- -L 18789:127.0.0.1:18789Open http://127.0.0.1:18789/ and paste your Gateway token.
Updates
cd ~/moltbot
git pull
docker compose build
docker compose up -dTroubleshooting
- Gateway not reachable: check
docker compose logs -f moltbot-gatewayand confirm the port mapping is loopback-only. - Out of memory: start with
e2-small(2GB) rather thane2-micro.
Further reading
- Docker flow: /docs/install/docker/
- Gateway security: /docs/gateway/security/
- Remote access: /docs/web/