Self-Updating OpenClaw in Docker with GitHub Actions: What Worked and Why I Shut It Down

Published on
7 min read.
Tags: CI/CDGitHubDevOpsAI

From March to June 2026 I ran OpenClaw in Docker on the cheapest Hetzner VPS in Helsinki, and it could update itself. The assistant, which I called Miki, edited its own repo and pushed to main. GitHub Actions built a new image, pushed it to GHCR and redeployed the VPS over SSH. Miki never had access to the Docker socket.

Out of 57 Actions runs, 50 went green. Two builds failed in April, so two OpenClaw bumps never reached the VPS and the bot kept running. The health-gated rollback added in October never ran on a real server, and I deleted the VPS anyway, because the server and OpenRouter bills weren't worth it for something I barely used.

The setup in short

  • The repo (miki-docker-config) holds a Dockerfile, docker-compose.yml, the baseline config/openclaw.json, skills, and one workflow.
  • On a push to main, Actions builds the image and pushes two tags to GHCR: latest and the 7-character commit SHA.
  • A second job SSHes into the VPS, pulls the SHA image, writes it to .env and restarts the gateway container.
  • The VPS is a Hetzner CX22 (2 vCPU, 4 GB, Ubuntu 24.04, about €4 a month). Port 22 is the only inbound port, and the dashboard goes through an SSH tunnel.

Why build in GitHub Actions instead of on the VPS

For the first few days the compose file built the image on the VPS itself. I moved the build to Actions because I didn't want the server doing anything except running OpenClaw. A CX22 is small, and the image installs a lot: OpenClaw, gh, uv, qmd, agent-browser with its bundled browser. GitHub's runners build it faster and more reliably, with a layer cache (type=gha) between runs.

It also means a broken build fails on GitHub, and the running bot keeps its current image.

Why the Docker socket stays unmounted

Mounting /var/run/docker.sock is how a container gets to manage Docker on its host. The compose file, based on OpenClaw's, ships that line commented out for sandbox mode:

# - /var/run/docker.sock:/var/run/docker.sock

Access to that socket is root on the host. The gateway reads Discord messages and runs tools, so one prompt injection with the socket mounted is enough to take over the server. With the repo-driven setup Miki can change anything in git, but deploying is CI's job.

Put every tool in the image

Anything you npm install -g inside a running container is gone once compose recreates it with a new image, so every tool the agents need goes into the image. The OpenClaw version is pinned as a build arg:

FROM node:22-bookworm-slim

# ...apt packages, yq, uv, gh, biome, ast-grep

ARG OPENCLAW_VERSION=2026.5.7
RUN npm install -g openclaw@${OPENCLAW_VERSION}

Upgrading OpenClaw is a one-line change to that number. That's the change Miki made most often.

The workflow

It runs on pushes to main that touch the image or its config:

on:
  push:
    branches: [main]
    paths:
      - Dockerfile
      - docker-compose.yml
      - docker/**
      - config/**
      - scripts/**
      - .github/workflows/**
      - skills/**

The build job logs in to GHCR with the built-in GITHUB_TOKEN and pushes both tags:

- name: Get short SHA
  id: short-sha
  run: echo "sha=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT

- name: Build and push
  uses: docker/build-push-action@v6
  with:
    context: .
    push: true
    tags: |
      ${{ env.IMAGE }}:latest
      ${{ env.IMAGE }}:${{ steps.short-sha.outputs.sha }}
    cache-from: type=gha
    cache-to: type=gha,mode=max

The deploy job needs the build to pass, then runs a script on the VPS with appleboy/ssh-action. Host, user and repo path are repo variables, and the private key is the VPS_SSH_KEY secret. For most of the setup's life the script looked like this:

set -e
cd "$VPS_REPO_PATH"

GHCR_TOKEN=$(grep '^GHCR_TOKEN=' .env | cut -d= -f2-)
echo "$GHCR_TOKEN" | docker login ghcr.io -u henggana --password-stdin

git pull origin main
docker pull "$SHA_TAG"
sed -i "s|^OPENCLAW_IMAGE=.*|OPENCLAW_IMAGE=$SHA_TAG|" .env

OPENCLAW_REPLACE_CONFIG=1 bash scripts/sync-config.sh
docker compose up -d --no-deps openclaw-gateway
docker logout ghcr.io

A few details:

  • docker pull runs before the restart, so the old container keeps serving while the new image downloads. The restart itself costs about 10 to 15 seconds.
  • Compose reads the tag with a fallback, image: ${OPENCLAW_IMAGE:-ghcr.io/henggana/miki-docker-config:latest}, so the VPS always runs a SHA tag and latest is only for fresh setups.
  • sync-config.sh copies the tracked config/openclaw.json over the live one and saves a timestamped .bak first.
  • The GHCR login on the VPS uses a classic personal access token, because fine-grained tokens don't support packages. The token lives in the VPS .env, not in the workflow.

What Miki changed by itself

Miki wrote 68 of the repo's 156 commits, all pushed straight to main without a pull request. It bumped OpenClaw eight times, ending at 2026.5.7, added tools to the image, wired up gh auth inside the container, set up new agent profiles and Discord channels, and promoted its live config back into the tracked baseline. A typical week in April:

2026-04-14 Miki  fix(docker): install qmd from npm release for stable CI builds
2026-04-14 Miki  chore(docker): bump OpenClaw to 2026.4.14
2026-04-13 Miki  chore(docker): bump OpenClaw to 2026.4.12
2026-04-13 Miki  chore(config): promote latest live openclaw baseline

Both builds on April 13 and 14 failed in the build job. The version bumps themselves were fine. According to the fix commit, the step that broke was qmd, OpenClaw's memory backend, which the Dockerfile cloned and compiled from source with Bun. Because the deploy job needs the build, nothing reached the VPS. The bot kept running the last good image while Miki replaced the source build with the npm release (npm install -g @tobilu/qmd@2.1.0), and the next push went green.

What never got tested

The script above didn't check whether the new container actually came up. A green run only meant the commands succeeded. The compose file did have a healthcheck:

healthcheck:
  test:
    [
      "CMD",
      "node",
      "-e",
      "fetch('http://127.0.0.1:18789/healthz').then((r)=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))",
    ]
  interval: 30s
  timeout: 5s
  retries: 5
  start_period: 20s

In October, after I'd stopped using the bot, a Claude Code session moved the deploy step into scripts/deploy.sh, which waits for that healthcheck and rolls back on failure:

  1. Remember the current OPENCLAW_IMAGE from .env.
  2. Pull the new SHA image, write it to .env, sync the config.
  3. Restart the gateway and poll docker inspect for healthy, for up to 120 seconds.
  4. If it isn't healthy, print the last 50 log lines, restore the old tag and the config backup, restart, and exit 1 so the run goes red.

That script never ran on a real server. The first run after it merged failed at the SSH step:

ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

I wasn't using the bot, so I never fixed it. The last successful deploy was June 5. The rollback logic was only tested with a stubbed docker command.

The SSH key also never got restricted. It logged in as the miki user, which is in the docker group, so anyone holding that GitHub secret effectively had root on the VPS. The fix would have been an authorized_keys entry with command="..." so the key could only run the deploy script.

Why I shut it down

I needed the server money for other things, and the LLM calls through OpenRouter cost money on top of that. I also didn't really use Miki as an assistant. It was an exploratory project, a way to learn a tool everyone was talking about. Once I'd learned what I wanted, nothing I used it for justified the monthly cost, so I deleted the VPS.

TL;DR

A self-updating OpenClaw in Docker can work without the Docker socket. The assistant pushes to its own repo. GitHub Actions builds the image, pushes latest and a SHA tag to GHCR, SSHes into the VPS, writes the SHA to OPENCLAW_IMAGE and runs docker compose up -d --no-deps openclaw-gateway. A broken build never reaches the server.