2026-02-28 16:11:58 -05:00
|
|
|
# ── Timmy Time — Development Compose ────────────────────────────────────────
|
2026-02-22 16:21:32 -05:00
|
|
|
#
|
|
|
|
|
# Services
|
|
|
|
|
# dashboard FastAPI app + swarm coordinator (always on)
|
2026-02-28 16:11:58 -05:00
|
|
|
# timmy Sovereign AI agent (separate container)
|
2026-02-22 16:21:32 -05:00
|
|
|
# agent Swarm worker template — scale with:
|
|
|
|
|
# docker compose up --scale agent=N --profile agents
|
|
|
|
|
#
|
|
|
|
|
# Volumes
|
|
|
|
|
# timmy-data Shared SQLite (data/swarm.db + data/timmy.db)
|
|
|
|
|
#
|
|
|
|
|
# Usage
|
|
|
|
|
# make docker-build build the image
|
|
|
|
|
# make docker-up start dashboard only
|
|
|
|
|
# make docker-agent add one agent worker
|
|
|
|
|
# make docker-down stop everything
|
|
|
|
|
# make docker-logs tail logs
|
2026-02-28 16:11:58 -05:00
|
|
|
#
|
|
|
|
|
# ── Security note: root user in dev ─────────────────────────────────────────
|
|
|
|
|
# This dev compose runs containers as root (user: "0:0") so that
|
|
|
|
|
# bind-mounted host files (./src, ./static) are readable regardless of
|
|
|
|
|
# host UID/GID — the #1 cause of 403 errors on macOS.
|
|
|
|
|
#
|
|
|
|
|
# Production (docker-compose.prod.yml) uses NO bind mounts and runs as
|
|
|
|
|
# the Dockerfile's non-root "timmy" user. Never expose this dev compose
|
|
|
|
|
# to untrusted networks.
|
|
|
|
|
#
|
|
|
|
|
# ── Ollama host access ──────────────────────────────────────────────────────
|
|
|
|
|
# By default OLLAMA_URL points to http://host.docker.internal:11434 which
|
|
|
|
|
# reaches Ollama running on the Docker host (macOS/Windows native).
|
|
|
|
|
#
|
|
|
|
|
# Linux: The extra_hosts entry maps host.docker.internal → host-gateway,
|
|
|
|
|
# which resolves to the host IP on Docker 20.10+. If you run an
|
|
|
|
|
# older Docker version, set OLLAMA_URL=http://172.17.0.1:11434
|
|
|
|
|
# in your .env file instead.
|
|
|
|
|
#
|
|
|
|
|
# Containerised Ollama: Use docker-compose.microservices.yml which runs
|
|
|
|
|
# Ollama as a sibling container on the same network.
|
2026-02-22 16:21:32 -05:00
|
|
|
|
|
|
|
|
services:
|
|
|
|
|
|
|
|
|
|
# ── Dashboard (coordinator + FastAPI) ──────────────────────────────────────
|
|
|
|
|
dashboard:
|
|
|
|
|
build: .
|
|
|
|
|
image: timmy-time:latest
|
|
|
|
|
container_name: timmy-dashboard
|
2026-02-28 16:11:58 -05:00
|
|
|
user: "0:0" # dev only — see security note above
|
2026-02-22 16:21:32 -05:00
|
|
|
ports:
|
|
|
|
|
- "8000:8000"
|
|
|
|
|
volumes:
|
|
|
|
|
- timmy-data:/app/data
|
|
|
|
|
- ./src:/app/src # live-reload: source changes reflect immediately
|
|
|
|
|
- ./static:/app/static # live-reload: CSS/asset changes reflect immediately
|
|
|
|
|
environment:
|
|
|
|
|
DEBUG: "true"
|
|
|
|
|
OLLAMA_URL: "${OLLAMA_URL:-http://host.docker.internal:11434}"
|
feat: add Grok (xAI) as opt-in premium backend with monetization
- Add GrokBackend class in src/timmy/backends.py with full sync/async
support, health checks, usage stats, and cost estimation in sats
- Add consult_grok tool to Timmy's toolkit for proactive Grok queries
- Extend cascade router with Grok provider type for failover chain
- Add Grok Mode toggle card to Mission Control dashboard (HTMX live)
- Add "Ask Grok" button on chat input for direct Grok queries
- Add /grok/* routes: status, toggle, chat, stats endpoints
- Integrate Lightning invoice generation for Grok usage monetization
- Add GROK_ENABLED, XAI_API_KEY, GROK_DEFAULT_MODEL, GROK_MAX_SATS_PER_QUERY,
GROK_FREE config settings via pydantic-settings
- Update .env.example and docker-compose.yml with Grok env vars
- Add 21 tests covering backend, tools, and route endpoints (all green)
Local-first ethos preserved: Grok is premium augmentation only,
disabled by default, and Lightning-payable when enabled.
https://claude.ai/code/session_01FygwN8wS8J6WGZ8FPb7XGV
2026-02-27 01:12:51 +00:00
|
|
|
# Grok (xAI) — opt-in premium cloud backend
|
|
|
|
|
GROK_ENABLED: "${GROK_ENABLED:-false}"
|
|
|
|
|
XAI_API_KEY: "${XAI_API_KEY:-}"
|
|
|
|
|
GROK_DEFAULT_MODEL: "${GROK_DEFAULT_MODEL:-grok-3-fast}"
|
2026-02-22 16:21:32 -05:00
|
|
|
extra_hosts:
|
2026-02-28 16:11:58 -05:00
|
|
|
- "host.docker.internal:host-gateway" # Linux: maps to host IP
|
2026-02-22 16:21:32 -05:00
|
|
|
networks:
|
|
|
|
|
- swarm-net
|
|
|
|
|
restart: unless-stopped
|
|
|
|
|
healthcheck:
|
|
|
|
|
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
|
|
|
|
interval: 30s
|
|
|
|
|
timeout: 5s
|
|
|
|
|
retries: 3
|
2026-02-28 15:01:48 -05:00
|
|
|
start_period: 30s
|
2026-02-22 16:21:32 -05:00
|
|
|
|
|
|
|
|
# ── Timmy — sovereign AI agent (separate container) ───────────────────────
|
|
|
|
|
timmy:
|
|
|
|
|
build: .
|
|
|
|
|
image: timmy-time:latest
|
|
|
|
|
container_name: timmy-agent
|
|
|
|
|
volumes:
|
|
|
|
|
- timmy-data:/app/data
|
|
|
|
|
- ./src:/app/src
|
|
|
|
|
environment:
|
|
|
|
|
COORDINATOR_URL: "http://dashboard:8000"
|
|
|
|
|
OLLAMA_URL: "${OLLAMA_URL:-http://host.docker.internal:11434}"
|
|
|
|
|
TIMMY_AGENT_ID: "timmy"
|
|
|
|
|
extra_hosts:
|
|
|
|
|
- "host.docker.internal:host-gateway"
|
|
|
|
|
command: ["python", "-m", "timmy.docker_agent"]
|
|
|
|
|
networks:
|
|
|
|
|
- swarm-net
|
|
|
|
|
depends_on:
|
|
|
|
|
dashboard:
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
restart: unless-stopped
|
|
|
|
|
|
|
|
|
|
# ── Agent worker template ───────────────────────────────────────────────────
|
|
|
|
|
# Scale horizontally: docker compose up --scale agent=4 --profile agents
|
|
|
|
|
# Each container gets a unique AGENT_ID via the replica index.
|
|
|
|
|
agent:
|
|
|
|
|
build: .
|
|
|
|
|
image: timmy-time:latest
|
|
|
|
|
profiles:
|
|
|
|
|
- agents
|
|
|
|
|
volumes:
|
|
|
|
|
- timmy-data:/app/data
|
|
|
|
|
- ./src:/app/src
|
|
|
|
|
environment:
|
|
|
|
|
COORDINATOR_URL: "http://dashboard:8000"
|
|
|
|
|
OLLAMA_URL: "${OLLAMA_URL:-http://host.docker.internal:11434}"
|
|
|
|
|
AGENT_NAME: "${AGENT_NAME:-Worker}"
|
|
|
|
|
AGENT_CAPABILITIES: "${AGENT_CAPABILITIES:-general}"
|
|
|
|
|
extra_hosts:
|
|
|
|
|
- "host.docker.internal:host-gateway"
|
|
|
|
|
command: ["sh", "-c", "python -m swarm.agent_runner --agent-id agent-$(hostname) --name $${AGENT_NAME:-Worker}"]
|
|
|
|
|
networks:
|
|
|
|
|
- swarm-net
|
|
|
|
|
depends_on:
|
|
|
|
|
dashboard:
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
restart: unless-stopped
|
|
|
|
|
|
|
|
|
|
# ── Shared volume ─────────────────────────────────────────────────────────────
|
2026-02-25 18:08:57 +00:00
|
|
|
# NOTE: the data/ directory must exist before running docker compose up.
|
|
|
|
|
# `make docker-up` and `make up` handle this automatically.
|
|
|
|
|
# If running docker compose directly, first run: mkdir -p data
|
2026-02-22 16:21:32 -05:00
|
|
|
volumes:
|
|
|
|
|
timmy-data:
|
|
|
|
|
driver: local
|
|
|
|
|
driver_opts:
|
|
|
|
|
type: none
|
|
|
|
|
o: bind
|
|
|
|
|
device: "${PWD}/data"
|
|
|
|
|
|
|
|
|
|
# ── Internal network ──────────────────────────────────────────────────────────
|
|
|
|
|
networks:
|
|
|
|
|
swarm-net:
|
|
|
|
|
driver: bridge
|