|
| 1 | +# === ClawMachine Development === |
| 2 | +# Requirements: kind cluster (with kind-config.yaml for Cilium), docker, helm, kubectl, mise |
| 3 | +# Cluster setup: kind create cluster --name clawmachine --config kind-config.yaml |
| 4 | +# |
| 5 | +# Usage: |
| 6 | +# tilt up # interactive dev (ESO + Cilium) |
| 7 | +# tilt ci # CI mode (build + deploy + verify) |
| 8 | +# tilt up -- --no-cilium # skip Cilium |
| 9 | +# tilt up -- --1password-connect # include 1Password Connect (needs credentials) |
| 10 | +# tilt up -- --no-external-secrets # skip ESO |
| 11 | + |
| 12 | +load('ext://namespace', 'namespace_create') |
| 13 | +load('ext://helm_remote', 'helm_remote') |
| 14 | + |
| 15 | +# Parse args — all three infra deps enabled by default |
| 16 | +config.define_bool('cilium') |
| 17 | +config.define_bool('external-secrets') |
| 18 | +config.define_bool('1password-connect') |
| 19 | +cfg = config.parse() |
| 20 | +enable_cilium = cfg.get('cilium', True) |
| 21 | +enable_eso = cfg.get('external-secrets', True) |
| 22 | +enable_op_connect = cfg.get('1password-connect', False) |
| 23 | + |
| 24 | +# --- Namespaces --- |
| 25 | +namespace_create('claw-machine') |
| 26 | + |
| 27 | +# --- Build Steps --- |
| 28 | + |
| 29 | +# Chart packaging — embeds bot charts into the Go binary |
| 30 | +local_resource( |
| 31 | + 'chart-package', |
| 32 | + cmd='cd .. && mise run charts', |
| 33 | + deps=[ |
| 34 | + '../control-plane/charts/picoclaw', |
| 35 | + '../control-plane/charts/ironclaw', |
| 36 | + '../control-plane/charts/clawmachine', |
| 37 | + '../control-plane/charts/openclaw', |
| 38 | + '../control-plane/charts/busybox', |
| 39 | + '../control-plane/charts/vendor', |
| 40 | + ], |
| 41 | + labels=['build'], |
| 42 | +) |
| 43 | + |
| 44 | +# --- Bot Images (deployed at runtime by the control plane, not by Tilt) --- |
| 45 | +# Use local_resource so they build, load into kind, and show up in the UI. |
| 46 | + |
| 47 | +local_resource( |
| 48 | + 'picoclaw-image', |
| 49 | + cmd='docker build -t ghcr.io/zackerydev/picoclaw:0.1.2 ../docker/picoclaw && kind load docker-image ghcr.io/zackerydev/picoclaw:0.1.2 --name clawmachine', |
| 50 | + deps=['../docker/picoclaw'], |
| 51 | + labels=['build'], |
| 52 | +) |
| 53 | + |
| 54 | +local_resource( |
| 55 | + 'ironclaw-image', |
| 56 | + cmd='docker build -t ghcr.io/zackerydev/ironclaw:0.11.1 ../docker/ironclaw && kind load docker-image ghcr.io/zackerydev/ironclaw:0.11.1 --name clawmachine', |
| 57 | + deps=['../docker/ironclaw'], |
| 58 | + labels=['build'], |
| 59 | +) |
| 60 | + |
| 61 | +local_resource( |
| 62 | + 'toolbox-image', |
| 63 | + cmd='docker build -t ghcr.io/zackerydev/clawmachine-toolbox:0.1.0 ../docker/toolbox && kind load docker-image ghcr.io/zackerydev/clawmachine-toolbox:0.1.0 --name clawmachine', |
| 64 | + deps=['../docker/toolbox'], |
| 65 | + labels=['build'], |
| 66 | +) |
| 67 | + |
| 68 | +local_resource( |
| 69 | + 'openclaw-image', |
| 70 | + cmd='docker build -t ghcr.io/zackerydev/openclaw:2026.2.21 ../docker/openclaw && kind load docker-image ghcr.io/zackerydev/openclaw:2026.2.21 --name clawmachine', |
| 71 | + deps=['../docker/openclaw'], |
| 72 | + labels=['build'], |
| 73 | +) |
| 74 | + |
| 75 | +# --- Control Plane --- |
| 76 | + |
| 77 | +docker_build( |
| 78 | + 'clawmachine', |
| 79 | + '../control-plane', |
| 80 | + ignore=[ |
| 81 | + 'node_modules', |
| 82 | + '.gocache', |
| 83 | + 'styles', |
| 84 | + 'e2e', |
| 85 | + '.air.toml', |
| 86 | + '.prettierrc.yaml', |
| 87 | + '.env.example', |
| 88 | + 'compose.yml', |
| 89 | + 'package.yaml', |
| 90 | + 'pnpm-lock.yaml', |
| 91 | + ], |
| 92 | + live_update=[ |
| 93 | + sync('../control-plane/templates', '/app/templates'), |
| 94 | + sync('../control-plane/static', '/app/static'), |
| 95 | + ], |
| 96 | +) |
| 97 | + |
| 98 | +# Backup/restore jobs in bot charts default to ghcr.io/zackerydev/clawmachine:0.1.0. |
| 99 | +# Mirror the local control-plane image to that ref inside kind to avoid ImagePullBackOff in dev. |
| 100 | +local_resource( |
| 101 | + 'clawmachine-backup-image', |
| 102 | + cmd=' && '.join([ |
| 103 | + 'docker image inspect clawmachine:latest >/dev/null 2>&1 || docker build -t clawmachine:latest ../control-plane', |
| 104 | + 'docker tag clawmachine:latest ghcr.io/zackerydev/clawmachine:0.1.0', |
| 105 | + 'kind load docker-image ghcr.io/zackerydev/clawmachine:0.1.0 --name clawmachine', |
| 106 | + ]), |
| 107 | + deps=['../control-plane'], |
| 108 | + labels=['build'], |
| 109 | +) |
| 110 | + |
| 111 | +# --- Infrastructure --- |
| 112 | + |
| 113 | +# External Secrets Operator (default: on) |
| 114 | +# Must wait for Cilium CNI — without networking, pods can't reach the API server |
| 115 | +if enable_eso: |
| 116 | + helm_remote( |
| 117 | + 'external-secrets', |
| 118 | + repo_url='https://charts.external-secrets.io', |
| 119 | + release_name='external-secrets', |
| 120 | + namespace='external-secrets', |
| 121 | + create_namespace=True, |
| 122 | + ) |
| 123 | + if enable_cilium: |
| 124 | + k8s_resource('external-secrets', resource_deps=['cilium'], labels=['infra']) |
| 125 | + k8s_resource('external-secrets-webhook', resource_deps=['cilium'], labels=['infra']) |
| 126 | + k8s_resource('external-secrets-cert-controller', resource_deps=['cilium'], labels=['infra']) |
| 127 | + |
| 128 | +# Cilium CNI (default: on — Kind's kindnet doesn't enforce NetworkPolicies) |
| 129 | +# Cilium provides DNS-aware network policies via CiliumNetworkPolicy + toFQDNs, |
| 130 | +# plus Hubble for flow observability. Replaces Calico as of HL-241. |
| 131 | +if enable_cilium: |
| 132 | + local_resource( |
| 133 | + 'cilium', |
| 134 | + cmd=' && '.join([ |
| 135 | + 'helm repo add cilium https://helm.cilium.io/ 2>/dev/null || true', |
| 136 | + 'helm repo update cilium', |
| 137 | + 'helm upgrade --install cilium cilium/cilium' |
| 138 | + + ' --namespace kube-system' |
| 139 | + + ' --set operator.replicas=1' |
| 140 | + + ' --set hubble.relay.enabled=true' |
| 141 | + + ' --set hubble.ui.enabled=true' |
| 142 | + + ' --set kubeProxyReplacement=false' |
| 143 | + + ' --set socketLB.hostNamespaceOnly=true' |
| 144 | + + ' --wait --timeout 120s', |
| 145 | + 'echo "Waiting for Cilium daemonset..."', |
| 146 | + 'kubectl -n kube-system rollout status daemonset/cilium --timeout=120s', |
| 147 | + ]), |
| 148 | + labels=['infra'], |
| 149 | + ) |
| 150 | + local_resource( |
| 151 | + 'hubble-ui-port-forward', |
| 152 | + cmd='kubectl -n kube-system get svc hubble-ui >/dev/null', |
| 153 | + serve_cmd='kubectl -n kube-system port-forward svc/hubble-ui 12000:80', |
| 154 | + resource_deps=['cilium'], |
| 155 | + labels=['infra'], |
| 156 | + ) |
| 157 | + |
| 158 | +# 1Password Connect Server (default: off) |
| 159 | +# Pod won't be ready without op-credentials secret — that's expected in dev. |
| 160 | +# Ignore readiness so tilt ci doesn't block on it. |
| 161 | +if enable_op_connect: |
| 162 | + helm_remote( |
| 163 | + 'connect', |
| 164 | + repo_url='https://1password.github.io/connect-helm-charts', |
| 165 | + release_name='connect', |
| 166 | + namespace='1password', |
| 167 | + create_namespace=True, |
| 168 | + ) |
| 169 | + k8s_resource( |
| 170 | + 'onepassword-connect', |
| 171 | + pod_readiness='ignore', |
| 172 | + labels=['infra'], |
| 173 | + ) |
| 174 | + |
| 175 | +# --- LocalStack (S3-compatible endpoint for backup/restore testing) --- |
| 176 | + |
| 177 | +k8s_yaml(blob(""" |
| 178 | +apiVersion: apps/v1 |
| 179 | +kind: Deployment |
| 180 | +metadata: |
| 181 | + name: localstack |
| 182 | + namespace: claw-machine |
| 183 | + labels: |
| 184 | + app: localstack |
| 185 | +spec: |
| 186 | + replicas: 1 |
| 187 | + selector: |
| 188 | + matchLabels: |
| 189 | + app: localstack |
| 190 | + template: |
| 191 | + metadata: |
| 192 | + labels: |
| 193 | + app: localstack |
| 194 | + spec: |
| 195 | + containers: |
| 196 | + - name: localstack |
| 197 | + image: localstack/localstack:latest |
| 198 | + ports: |
| 199 | + - containerPort: 4566 |
| 200 | + env: |
| 201 | + - name: SERVICES |
| 202 | + value: s3 |
| 203 | + - name: DEFAULT_REGION |
| 204 | + value: us-east-1 |
| 205 | + readinessProbe: |
| 206 | + httpGet: |
| 207 | + path: /_localstack/health |
| 208 | + port: 4566 |
| 209 | + initialDelaySeconds: 5 |
| 210 | + periodSeconds: 10 |
| 211 | +--- |
| 212 | +apiVersion: v1 |
| 213 | +kind: Service |
| 214 | +metadata: |
| 215 | + name: localstack |
| 216 | + namespace: claw-machine |
| 217 | + labels: |
| 218 | + app: localstack |
| 219 | +spec: |
| 220 | + selector: |
| 221 | + app: localstack |
| 222 | + ports: |
| 223 | + - port: 4566 |
| 224 | + targetPort: 4566 |
| 225 | +""")) |
| 226 | + |
| 227 | +k8s_resource( |
| 228 | + 'localstack', |
| 229 | + port_forwards=['4566:4566'], |
| 230 | + labels=['infra'], |
| 231 | +) |
| 232 | + |
| 233 | +# --- Deploy ClawMachine --- |
| 234 | + |
| 235 | +k8s_yaml(helm( |
| 236 | + '../control-plane/charts/clawmachine', |
| 237 | + name='clawmachine', |
| 238 | + namespace='claw-machine', |
| 239 | + set=[ |
| 240 | + 'image.repository=clawmachine', |
| 241 | + 'image.tag=latest', |
| 242 | + 'image.pullPolicy=Never', |
| 243 | + 'replicaCount=1', |
| 244 | + 'devMode=true', |
| 245 | + # Allow Tilt live_update file sync to write to /app/templates and /app/static. |
| 246 | + # readOnlyRootFilesystem blocks kubectl exec writes used by live_update. |
| 247 | + 'securityContext.readOnlyRootFilesystem=false', |
| 248 | + ], |
| 249 | +)) |
| 250 | + |
| 251 | +k8s_resource( |
| 252 | + 'clawmachine', |
| 253 | + port_forwards=['8080:8080'], |
| 254 | + resource_deps=['chart-package'], |
| 255 | + labels=['app'], |
| 256 | +) |
0 commit comments