-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
236 lines (217 loc) · 9.86 KB
/
Copy pathMakefile
File metadata and controls
236 lines (217 loc) · 9.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
SHELL := /bin/bash
.DEFAULT_GOAL := help
DOCKER ?= docker
IMAGE ?= pdparchitect/buzzbox:local
CONTAINER ?= buzzbox
NATIVE_ARCH := $(shell uname -m | sed \
-e 's/^x86_64$$/amd64/' \
-e 's/^aarch64$$/arm64/')
PLATFORM ?= linux/$(NATIVE_ARCH)
TARGETARCH ?= $(word 2,$(subst /, ,$(PLATFORM)))
BUZZ_VERSION ?= 0.5.3
BUZZ_RELEASE_TAG ?= desktop-v0.5.3
BUZZ_DEB_SHA256 ?= ae20163ef481ccbf3531b9806996d7580a3a24f9258a54698c75fdcb8b16f14b
BUZZ_SOURCE_SHA ?= 3a96acea09b4a9e3f02c3a26cfb0607d2ccacf42
BUZZ_RELAY_IMAGE ?= ghcr.io/block/buzz:sha-3a96ace
DESKTOP_IMAGE ?= ghcr.io/pdparchitect/launcher-image-base-desktop:0.1.8
CODEX_VERSION ?= 0.145.0
CLAUDE_CODE_VERSION ?= 2.1.220
CODEX_ACP_VERSION ?= 1.1.7
CLAUDE_ACP_VERSION ?= 0.62.0
GOOSE_VERSION ?= 1.44.0
GOOSE_AMD64_SHA256 ?= 07febc8b4f73bdfdc3ece3d34d0e21b005f3a4f43008f95b85d6538da8f6bac1
GOOSE_ARM64_SHA256 ?= da6cb005d421b0bdcb83fe8386ba5ae8060ef17adf64641a684d4fc4b9e1c15f
BIND_ADDRESS ?= 127.0.0.1
PORT ?= 6903
RELAY_PORT ?= 3000
# The container-side ports. 6901 is the desktop base's and is not redeclared
# here, the same way hermes, openclaw, and petbox do not redeclare it.
RELAY_CONTAINER_PORT ?= 3000
HEALTH_PORT ?= 8080
BUZZ_NETWORK ?=
PUBLIC_RELAY_URL ?=
VNC_STATS ?= false
VOLUME_PREFIX ?= buzzbox
# Pass render nodes only. `--device=/dev/dri` would also hand over card*, the
# DRM master/modesetting node, which nothing in this container has a use for.
GPU_DEVICE := $(shell for node in /dev/dri/renderD*; do \
[ -e "$$node" ] && echo "--device=$$node"; done)
NETWORK_ARG := $(if $(strip $(BUZZ_NETWORK)),--network "$(BUZZ_NETWORK)",)
PUBLIC_RELAY_ENV := $(if $(strip $(PUBLIC_RELAY_URL)),--env "BUZZBOX_PUBLIC_RELAY_URL=$(PUBLIC_RELAY_URL)",)
.PHONY: help check build network run recreate up test smoke stop logs relay-log vnc-log status url size-report
help:
@echo "Buzzbox local Docker workflow"
@echo
@echo " make check Validate local scripts and pinned metadata"
@echo " make build Build $(IMAGE)"
@echo " make run Start or create the Buzzbox container"
@echo " make recreate Recreate the container without rebuilding"
@echo " make up Build and recreate the container"
@echo " make test Check, build, run, and smoke-test the environment"
@echo " make smoke Test the running desktop, relay, services, and agents"
@echo " make logs Follow container logs"
@echo " make relay-log Follow Buzz relay logs"
@echo " make vnc-log Follow the KasmVNC session log"
@echo " make status Show container and health status"
@echo " make stop Stop and remove the container"
@echo " make url Print the local desktop and relay URLs"
@echo " make size-report Report the graphical stack's share of the image"
@echo
@echo "Overrides: PORT=8080 RELAY_PORT=3001"
@echo " PLATFORM=linux/arm64 (default: $(PLATFORM))"
@echo " BUZZ_NETWORK=buzz-local"
@echo " PUBLIC_RELAY_URL=ws://buzzbox:3000 VNC_STATS=true"
check:
bash -n \
overlay/etc/desktop/session.d/10-buzz-desktop \
overlay/etc/desktop/startup.d/05-agent-runtime-trust \
overlay/etc/desktop/startup.d/10-buzz-stack \
overlay/usr/local/bin/agent-runtime-login \
overlay/usr/local/bin/buzzbox \
overlay/usr/local/bin/buzzbox-greeting \
overlay/usr/local/bin/buzznode-enrollment \
overlay/usr/local/bin/desktop-harness \
overlay/usr/local/bin/desktop-panel-status \
overlay/usr/local/bin/desktop-welcome \
tests/test-agent-runtime-login.sh tests/test-buzznode-enrollment.sh \
tests/test-desktop-theme.sh tests/smoke-container.sh
bash tests/test-agent-runtime-login.sh
bash tests/test-buzznode-enrollment.sh
bash tests/test-desktop-theme.sh
@grep -q "^ARG DESKTOP_IMAGE=$(DESKTOP_IMAGE)$$" Dockerfile
@grep -q "^ARG BUZZ_VERSION=$(BUZZ_VERSION)$$" Dockerfile
@grep -q "^ARG BUZZ_RELEASE_TAG=$(BUZZ_RELEASE_TAG)$$" Dockerfile
@grep -q "^ARG BUZZ_DEB_SHA256=$(BUZZ_DEB_SHA256)$$" Dockerfile
@grep -q "^ARG BUZZ_SOURCE_SHA=$(BUZZ_SOURCE_SHA)$$" Dockerfile
@grep -q "^ARG BUZZ_RELAY_IMAGE=$(BUZZ_RELAY_IMAGE)$$" Dockerfile
@grep -q "^ARG CODEX_VERSION=$(CODEX_VERSION)$$" Dockerfile
@grep -q "^ARG CLAUDE_CODE_VERSION=$(CLAUDE_CODE_VERSION)$$" Dockerfile
@grep -q "^ARG CODEX_ACP_VERSION=$(CODEX_ACP_VERSION)$$" Dockerfile
@grep -q "^ARG CLAUDE_ACP_VERSION=$(CLAUDE_ACP_VERSION)$$" Dockerfile
@grep -q "^ARG GOOSE_VERSION=$(GOOSE_VERSION)$$" Dockerfile
@grep -q "^ARG GOOSE_AMD64_SHA256=$(GOOSE_AMD64_SHA256)$$" Dockerfile
@grep -q "^ARG GOOSE_ARM64_SHA256=$(GOOSE_ARM64_SHA256)$$" Dockerfile
@grep -q 'RUN kasm-patch "Buzzbox"' Dockerfile
@grep -q ' BUZZ_RELAY_PORT=$(RELAY_CONTAINER_PORT) \\' Dockerfile
@grep -q ' BUZZ_HEALTH_PORT=$(HEALTH_PORT) \\' Dockerfile
@grep -q '^EXPOSE $(RELAY_CONTAINER_PORT)$$' Dockerfile
@grep -q 'http://127.0.0.1:6902/healthz' Dockerfile
@grep -q 'cd /workspace' overlay/etc/bash.bashrc.d/buzzbox-prompt.sh
@grep -q 'BUZZBOX_CODEX_SANDBOX_MODE' overlay/etc/desktop/startup.d/05-agent-runtime-trust
@grep -q 'BUZZBOX_CODEX_SANDBOX_MODE' README.md
@grep -Fq 'service_user=agent' overlay/etc/desktop/startup.d/10-buzz-stack
@grep -Fq 'runtime-managed volume' overlay/etc/desktop/startup.d/10-buzz-stack
@grep -q '\[ -n "$${PS1:-}" \]' overlay/etc/bash.bashrc.d/buzzbox-prompt.sh
@test "$$(jq -er '.schemaVersion' launcher/application.json)" = 2
@test "$$(jq -er '.mounts[] | select(.name == "private/services") | .storage' launcher/application.json)" = volume
@! jq -e 'has("image")' launcher/application.json >/dev/null
@jq -e '.interfaces.health.kind == "health" and .interfaces.health.port == 6902 and .interfaces.health.path == "/healthz"' launcher/application.json >/dev/null
@jq -e '.interfaces.notifications.kind == "notifications" and .interfaces.notifications.port == 6902 and .interfaces.notifications.path == "/notifications"' launcher/application.json >/dev/null
@jq -e '.interfaces.preview.kind == "preview" and .interfaces.preview.port == 6902 and .interfaces.preview.path == "/preview.jpg"' launcher/application.json >/dev/null
@for asset in $$(jq -er '.media.icon, .media.cover, .media.screenshots[].source' launcher/application.json); do \
test -f "launcher/$$asset"; \
done
@echo "Buzzbox metadata and shell syntax are valid."
build:
$(DOCKER) build \
--platform "$(PLATFORM)" \
--build-arg "TARGETARCH=$(TARGETARCH)" \
--build-arg "DESKTOP_IMAGE=$(DESKTOP_IMAGE)" \
--build-arg "BUZZ_VERSION=$(BUZZ_VERSION)" \
--build-arg "BUZZ_RELEASE_TAG=$(BUZZ_RELEASE_TAG)" \
--build-arg "BUZZ_DEB_SHA256=$(BUZZ_DEB_SHA256)" \
--build-arg "BUZZ_SOURCE_SHA=$(BUZZ_SOURCE_SHA)" \
--build-arg "BUZZ_RELAY_IMAGE=$(BUZZ_RELAY_IMAGE)" \
--build-arg "CODEX_VERSION=$(CODEX_VERSION)" \
--build-arg "CLAUDE_CODE_VERSION=$(CLAUDE_CODE_VERSION)" \
--build-arg "CODEX_ACP_VERSION=$(CODEX_ACP_VERSION)" \
--build-arg "CLAUDE_ACP_VERSION=$(CLAUDE_ACP_VERSION)" \
--build-arg "GOOSE_VERSION=$(GOOSE_VERSION)" \
--build-arg "GOOSE_AMD64_SHA256=$(GOOSE_AMD64_SHA256)" \
--build-arg "GOOSE_ARM64_SHA256=$(GOOSE_ARM64_SHA256)" \
--tag "$(IMAGE)" \
.
network:
@if [ -n "$(strip $(BUZZ_NETWORK))" ]; then \
if ! $(DOCKER) network inspect "$(BUZZ_NETWORK)" >/dev/null 2>&1; then \
$(DOCKER) network create "$(BUZZ_NETWORK)" >/dev/null; \
echo "Created Docker network $(BUZZ_NETWORK)."; \
fi; \
fi
run: network
@if $(DOCKER) container inspect "$(CONTAINER)" >/dev/null 2>&1; then \
if [ "$$($(DOCKER) container inspect --format '{{.State.Running}}' "$(CONTAINER)")" = "true" ]; then \
echo "Container $(CONTAINER) is already running."; \
else \
$(DOCKER) start "$(CONTAINER)"; \
fi; \
else \
$(DOCKER) run --detach \
--name "$(CONTAINER)" \
--platform "$(PLATFORM)" \
--restart unless-stopped \
--shm-size 1g \
$(GPU_DEVICE) \
$(NETWORK_ARG) \
--publish "$(BIND_ADDRESS):$(PORT):6901" \
--publish "$(BIND_ADDRESS):$(RELAY_PORT):$(RELAY_CONTAINER_PORT)" \
$(PUBLIC_RELAY_ENV) \
--env "DESKTOP_VNC_STATS=$(VNC_STATS)" \
--volume "$(VOLUME_PREFIX)-workspace:/workspace" \
--volume "$(VOLUME_PREFIX)-services:/var/lib/buzzbox" \
--volume "$(VOLUME_PREFIX)-config:/home/agent/.config" \
--volume "$(VOLUME_PREFIX)-data:/home/agent/.local/share" \
--volume "$(VOLUME_PREFIX)-nest:/home/agent/.buzz" \
--volume "$(VOLUME_PREFIX)-codex:/home/agent/.codex" \
--volume "$(VOLUME_PREFIX)-claude:/home/agent/.claude" \
"$(IMAGE)"; \
fi
@$(MAKE) --no-print-directory url
recreate:
@$(MAKE) --no-print-directory stop
@$(MAKE) --no-print-directory run
up: build recreate
test: check up smoke
smoke:
@echo "Waiting for Buzzbox at http://$(BIND_ADDRESS):$(PORT) ..."
@ready=false; \
for attempt in $$(seq 1 60); do \
if curl --fail --silent "http://$(BIND_ADDRESS):$(PORT)/index.html" >/dev/null && \
$(DOCKER) exec "$(CONTAINER)" curl --fail --silent \
http://127.0.0.1:$(HEALTH_PORT)/_readiness >/dev/null; then \
ready=true; \
break; \
fi; \
sleep 2; \
done; \
if [ "$$ready" != "true" ]; then \
echo "Buzzbox did not become ready within 120 seconds."; \
$(DOCKER) logs --tail 150 "$(CONTAINER)" || true; \
exit 1; \
fi
@DOCKER="$(DOCKER)" bash tests/smoke-container.sh \
"$(CONTAINER)" "$(TARGETARCH)"
@echo "Buzzbox is ready with the desktop, relay, and agent runtimes."
stop:
@if $(DOCKER) container inspect "$(CONTAINER)" >/dev/null 2>&1; then \
$(DOCKER) rm --force "$(CONTAINER)"; \
else \
echo "Container $(CONTAINER) does not exist."; \
fi
logs:
$(DOCKER) logs --follow "$(CONTAINER)"
relay-log:
$(DOCKER) exec "$(CONTAINER)" \
tail --lines=200 --follow /var/log/launcher-desktop/buzz-relay.log
vnc-log:
$(DOCKER) exec "$(CONTAINER)" \
bash -c 'tail --lines=200 --follow /home/agent/.vnc/*:1.log'
status:
@$(DOCKER) ps --all \
--filter "name=^/$(CONTAINER)$$" \
--format 'table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'
url:
@echo "Desktop: http://$(BIND_ADDRESS):$(PORT)"
@echo "Relay: ws://$(BIND_ADDRESS):$(RELAY_PORT)"
size-report:
@DOCKER="$(DOCKER)" bash tools/size-report.sh "$(IMAGE)"