From 280fc25c1e9e21a3d3fcc411176ebf2326dbf35c Mon Sep 17 00:00:00 2001 From: Rau1CS Date: Fri, 20 Feb 2026 23:04:07 +0100 Subject: [PATCH] feat: add Docker deployment for third-party infrastructure Add Dockerfile, docker-compose.yml, and .dockerignore to enable running the automaton on any server or cloud provider with Docker. - Multi-stage build: build with pnpm + native deps, slim runtime - Non-root user with pre-created .automaton dir for volume permissions - Persistent named volume for wallet, database, config, and skills - TTY support for interactive setup wizard on first run - Graceful shutdown via SIGTERM - Add .claude/ to .gitignore Co-Authored-By: Claude Opus 4.6 --- .dockerignore | 13 +++++++++++++ .gitignore | 1 + Dockerfile | 40 ++++++++++++++++++++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ docker-compose.yml | 14 ++++++++++++++ 5 files changed, 91 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..b903ce48 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +node_modules/ +dist/ +.git/ +*.db +*.db-journal +*.db-wal +*.db-shm +.env +.DS_Store +*.tgz +.automaton/ +coverage/ +.github/ diff --git a/.gitignore b/.gitignore index d9cadf93..b1030545 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ dist/ *.tgz .automaton/wallet.json .automaton/state.db +.claude/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..06aca5a5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +# ── Build stage ────────────────────────────────────────────── +FROM node:20-slim AS build + +RUN corepack enable && corepack prepare pnpm@10.28.1 --activate + +# Native build deps for better-sqlite3 +RUN apt-get update && apt-get install -y python3 make g++ git && rm -rf /var/lib/apt/lists/* + +WORKDIR /app +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ +COPY packages/cli/package.json packages/cli/ +RUN pnpm install --frozen-lockfile + +COPY tsconfig.json ./ +COPY src/ src/ +COPY packages/ packages/ +RUN pnpm build + +# ── Runtime stage ──────────────────────────────────────────── +FROM node:20-slim + +RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* + +RUN useradd --create-home --shell /bin/bash automaton +RUN mkdir -p /home/automaton/.automaton && chown automaton:automaton /home/automaton/.automaton +USER automaton +WORKDIR /home/automaton/app + +COPY --from=build --chown=automaton:automaton /app/dist ./dist +COPY --from=build --chown=automaton:automaton /app/node_modules ./node_modules +COPY --from=build --chown=automaton:automaton /app/packages ./packages +COPY --from=build --chown=automaton:automaton /app/package.json ./ + +ENV HOME=/home/automaton +ENV NODE_ENV=production + +STOPSIGNAL SIGTERM + +ENTRYPOINT ["node", "dist/index.js"] +CMD ["--run"] diff --git a/README.md b/README.md index 053f0c5a..b42d8c33 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,29 @@ For automated sandbox provisioning: curl -fsSL https://conway.tech/automaton.sh | sh ``` +## Docker Deployment + +Run an automaton on any server or cloud provider with Docker: + +```bash +git clone https://github.com/Conway-Research/automaton.git +cd automaton +docker compose up -d +``` + +On first run, attach to the container to complete the interactive setup wizard: + +```bash +docker attach $(docker compose ps -q automaton) +``` + +Once setup completes, the automaton runs autonomously. Detach with `Ctrl+P, Ctrl+Q`. All state (wallet, database, config) persists in a Docker volume across restarts. + +To view logs: +```bash +docker compose logs -f +``` + ## How It Works Every automaton runs a continuous loop: **Think → Act → Observe → Repeat.** diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..3d9bec3a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +services: + automaton: + build: . + restart: unless-stopped + stdin_open: true # Required for interactive setup wizard on first run + tty: true # Required for interactive setup wizard on first run + volumes: + - automaton-data:/home/automaton/.automaton + environment: + - CONWAY_API_URL=${CONWAY_API_URL:-https://api.conway.tech} + - CONWAY_API_KEY=${CONWAY_API_KEY:-} + +volumes: + automaton-data: