Skip to content

A desktop coding agent with free access to frontier models.

TypeScript
7.4 KB
Raw Blame
# docker-compose.dev.yml — Dev testability stack (no custom Dockerfile)
#
# Usage (from repo root):
#   docker compose -f packaging/docker/docker-compose.dev.yml up
#
# Then open the printed Web UI URL — already wired to headless, no config needed.
#
# Env overrides (optional, via .env or export):
#   OMNIRUSH_TOKEN        — shared client token (auto-generated if unset)
#   OMNIRUSH_HOST_TOKEN   — host/admin token (auto-generated if unset)
#   OMNIRUSH_WORKSPACE    — host path to mount as workspace (default: ./workspace)
#   OMNIRUSH_PORT         — host port to map to container :8787 (default: 8787)
#   WEB_PORT              — host port to map to container :5173 (default: 5173)
#   OMNIRUSH_DEV_ID       — unique ID for this stack (default: default)
#   OMNIRUSH_DEV_MODE     — enables isolated OpenCode dev state
#   OMNIRUSH_PUBLIC_HOST  — browser-facing host/IP for LAN-accessible URLs
#   OMNIRUSH_DOCKER_DEV_MOUNT_HOST_OPENCODE=1 — import host OpenCode config/auth into the isolated dev state
#   OMNIRUSH_OPENCODE_CONFIG_DIR      — host OpenCode config dir detection override
#   OMNIRUSH_OPENCODE_DATA_DIR        — host OpenCode data dir detection override
#   OMNIRUSH_HOST_OPENCODE_CONFIG_DIR — import source for OpenCode config
#   OMNIRUSH_HOST_OPENCODE_DATA_DIR   — import source for OpenCode auth/data

x-shared: &shared
  image: node:22-bookworm-slim
  working_dir: /app
  volumes:
    # Mount the entire repo so both services share node_modules + source
    - ../../:/app
    - pnpm-store:/root/.local/share/pnpm/store
    - bun-install:/root/.bun
    - ${OMNIRUSH_WORKSPACE:-./workspace}:/workspace
    - ${OMNIRUSH_HOST_OPENCODE_CONFIG_DIR:-./workspace/.omnirush-host-opencode-config}:/persist/.config/opencode:ro
    - ${OMNIRUSH_HOST_OPENCODE_DATA_DIR:-./workspace/.omnirush-host-opencode-data}:/persist/.omnirush-host-opencode-data:ro

services:
  omnirush-server:
    <<: *shared
    entrypoint: ["/bin/sh", "-c"]
    command:
      - |
        set -e

        # --- Ensure workspace dir is writable ---
        mkdir -p /workspace && touch /workspace/.keep 2>/dev/null || true

        # --- Install system deps ---
        apt-get update -qq && apt-get install -y -qq --no-install-recommends \
          curl ca-certificates unzip git >/dev/null 2>&1

        # --- Install bun (cached in named volume) ---
        export BUN_INSTALL="/root/.bun"
        export PATH="$$BUN_INSTALL/bin:$$PATH"
        if ! command -v bun >/dev/null 2>&1; then
          echo "[omnirush-server] Installing bun..."
          curl -fsSL https://bun.sh/install | bash -s "bun-v1.3.14"
        fi

        # --- Enable pnpm via corepack ---
        corepack enable && corepack prepare [email protected] --activate

        # --- Install deps ---
        echo "[omnirush-server] Installing dependencies..."
        pnpm install --no-frozen-lockfile --network-concurrency 1 --child-concurrency 1

        # --- Build the server plugins and install the pinned OpenCode binary ---
        pnpm --filter omnirush-server build
        OPENCODE_VERSION=$$(node -e 'const fs=require("fs"); const parsed=JSON.parse(fs.readFileSync("/app/constants.json", "utf8")); process.stdout.write(String(parsed.opencodeVersion || "").trim().replace(/^v/, ""));')
        export OPENCODE_INSTALL_DIR="/root/.opencode/bin"
        mkdir -p "$$OPENCODE_INSTALL_DIR"
        if ! command -v opencode >/dev/null 2>&1; then
          curl -fsSL https://opencode.ai/install | bash -s -- --version "$$OPENCODE_VERSION" --no-modify-path
        fi
        export PATH="$$OPENCODE_INSTALL_DIR:$$PATH"
        export OMNIRUSH_MANAGE_OPENCODE=1
        export OMNIRUSH_OPENCODE_BIN="$$(command -v opencode)"
        export OMNIRUSH_EXTENSIONS_PLUGIN_DIR="/app/apps/server/dist/opencode-plugins"

        # --- Resolve tokens ---
        if [ -z "$$OMNIRUSH_TOKEN" ]; then
          OMNIRUSH_TOKEN=$$(cat /proc/sys/kernel/random/uuid)
          export OMNIRUSH_TOKEN
        fi
        if [ -z "$$OMNIRUSH_HOST_TOKEN" ]; then
          OMNIRUSH_HOST_TOKEN=$$(cat /proc/sys/kernel/random/uuid)
          export OMNIRUSH_HOST_TOKEN
        fi

        # Write tokens so the web service can source them
        mkdir -p /app/tmp
        printf 'OMNIRUSH_TOKEN=%s\nOMNIRUSH_HOST_TOKEN=%s\n' \
          "$$OMNIRUSH_TOKEN" "$$OMNIRUSH_HOST_TOKEN" > "/app/tmp/.dev-env-${OMNIRUSH_DEV_ID:-default}"

        echo ""
        echo "============================================"
        echo "  OmniRush.ai server"
        echo "  Server:     http://localhost:${OMNIRUSH_PORT:-8787}"
        echo "  Health:     http://localhost:${OMNIRUSH_PORT:-8787}/health"
        echo "  Token:      $$OMNIRUSH_TOKEN"
        echo "  Host token: $$OMNIRUSH_HOST_TOKEN"
        echo "============================================"
        echo ""

        exec pnpm --filter omnirush-server exec bun dist/cli.js \
          --workspace /workspace \
          --host 0.0.0.0 \
          --port 8787 \
          --token "$$OMNIRUSH_TOKEN" \
          --host-token "$$OMNIRUSH_HOST_TOKEN" \
          --approval auto \
          --cors "*" \
          --verbose
    ports:
      - "${OMNIRUSH_PORT:-8787}:8787"
    healthcheck:
      test: ["CMD-SHELL", "curl -sf http://localhost:8787/health || exit 1"]
      interval: 5s
      timeout: 5s
      retries: 30
      start_period: 90s
    environment:
      CI: "true"
      OMNIRUSH_TOKEN: ${OMNIRUSH_TOKEN:-}
      OMNIRUSH_HOST_TOKEN: ${OMNIRUSH_HOST_TOKEN:-}
      OMNIRUSH_DEV_ID: ${OMNIRUSH_DEV_ID:-default}
      OMNIRUSH_DEV_MODE: ${OMNIRUSH_DEV_MODE:-1}
      OMNIRUSH_DEV_OPENCODE_IMPORT_CONFIG_DIR: /persist/.config/opencode
      OMNIRUSH_DEV_OPENCODE_IMPORT_DATA_DIR: /persist/.omnirush-host-opencode-data

  web:
    <<: *shared
    depends_on:
      omnirush-server:
        condition: service_healthy
    entrypoint: ["/bin/sh", "-c"]
    command:
      - |
        set -e

        # --- Install system deps ---
        apt-get update -qq && apt-get install -y -qq --no-install-recommends \
          curl ca-certificates >/dev/null 2>&1

        # --- Bun + pnpm ---
        export BUN_INSTALL="/root/.bun"
        export PATH="$$BUN_INSTALL/bin:$$PATH"
        if ! command -v bun >/dev/null 2>&1; then
          curl -fsSL https://bun.sh/install | bash -s "bun-v1.3.14"
        fi
        corepack enable && corepack prepare [email protected] --activate

        # --- Read token written by omnirush-server ---
        if [ -f "/app/tmp/.dev-env-${OMNIRUSH_DEV_ID:-default}" ]; then
          . "/app/tmp/.dev-env-${OMNIRUSH_DEV_ID:-default}"
          export VITE_OMNIRUSH_TOKEN="$$OMNIRUSH_TOKEN"
        fi

        echo ""
        echo "============================================"
        echo "  OmniRush.ai web UI"
        echo "  URL:   http://localhost:${WEB_PORT:-5173}"
          echo "  Token: $${VITE_OMNIRUSH_TOKEN:-<see omnirush-server logs>}"
        echo "============================================"
        echo ""

        export VITE_OMNIRUSH_URL="http://${OMNIRUSH_PUBLIC_HOST:-localhost}:${OMNIRUSH_PORT:-8787}"
        export VITE_OMNIRUSH_PORT="${OMNIRUSH_PORT:-8787}"
        export VITE_ALLOWED_HOSTS="all"
        export HOST="0.0.0.0"
        export PORT="5173"

        exec pnpm --filter @omnirush/app exec vite \
          --host 0.0.0.0 \
          --port 5173 \
          --strictPort
    ports:
      - "${WEB_PORT:-5173}:5173"
    environment:
      OMNIRUSH_DEV_ID: ${OMNIRUSH_DEV_ID:-default}

volumes:
  pnpm-store:
    name: omnirush-dev-pnpm-store
  bun-install:
    name: omnirush-dev-bun-install