From c74c1a676c0ee328d52301652315fd0fe65e020d Mon Sep 17 00:00:00 2001 From: Harivansh Rathi Date: Sun, 12 Apr 2026 22:47:51 +0000 Subject: [PATCH] feat: phase 1 --- Dockerfile | 15 ++++++++++++++- microagent-init.sh | 13 +++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bc28135..7bd3a60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,15 @@ +FROM --platform=$BUILDPLATFORM golang:1.26.1 AS guestd-builder + +ARG TARGETOS +ARG TARGETARCH + +WORKDIR /src + +COPY go.mod go.sum ./ +COPY packages/guestd ./packages/guestd + +RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} go build -o /out/microagent-guestd ./packages/guestd/cmd/guestd + FROM public.ecr.aws/docker/library/ubuntu:24.04 SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -133,6 +145,7 @@ COPY microagent-init.sh /usr/local/bin/microagent-init COPY microagent-desktop-session.sh /usr/local/bin/microagent-desktop-session COPY microagent-network-up.sh /usr/local/bin/microagent-network-up COPY microagent-ready-agent.py /usr/local/bin/microagent-ready-agent +COPY --from=guestd-builder /out/microagent-guestd /usr/local/bin/microagent-guestd COPY defaults/.zshrc /home/node/.zshrc COPY defaults/.bashrc /home/node/.bashrc COPY defaults/.profile /home/node/.profile @@ -141,7 +154,7 @@ COPY defaults/AGENTS.md /home/node/AGENTS.md COPY terminfo/xterm-ghostty.terminfo /tmp/xterm-ghostty.terminfo COPY terminfo/xterm-kitty.terminfo /tmp/xterm-kitty.terminfo -RUN chmod 755 /usr/local/bin/microagent-init /usr/local/bin/microagent-desktop-session /usr/local/bin/microagent-network-up /usr/local/bin/microagent-ready-agent \ +RUN chmod 755 /usr/local/bin/microagent-init /usr/local/bin/microagent-desktop-session /usr/local/bin/microagent-network-up /usr/local/bin/microagent-ready-agent /usr/local/bin/microagent-guestd \ && chmod 755 /opt/desktop/scripts/apply-desktop-profile.sh \ && chown node:node /home/node/.zshrc /home/node/.bashrc /home/node/.profile /home/node/AGENTS.md \ && ln -sf /home/node/AGENTS.md /home/node/CLAUDE.md \ diff --git a/microagent-init.sh b/microagent-init.sh index b08de5d..586465d 100644 --- a/microagent-init.sh +++ b/microagent-init.sh @@ -38,6 +38,7 @@ cleanup() { [ -n "${ready_agent_pid:-}" ] && kill "$ready_agent_pid" >/dev/null 2>&1 || true [ -n "${sshd_pid:-}" ] && kill "$sshd_pid" >/dev/null 2>&1 || true [ -n "${desktop_pid:-}" ] && kill "$desktop_pid" >/dev/null 2>&1 || true + [ -n "${guestd_pid:-}" ] && kill "$guestd_pid" >/dev/null 2>&1 || true wait >/dev/null 2>&1 || true exit 0 } @@ -75,6 +76,13 @@ start_desktop() { desktop_pid=$! } +start_guestd() { + reap_if_needed "${guestd_pid:-}" + log "starting guestd on 49983" + /usr/local/bin/microagent-guestd >>/var/log/guestd.log 2>&1 & + guestd_pid=$! +} + trap cleanup INT TERM log "bringing up guest network" @@ -125,6 +133,7 @@ fi start_ready_agent start_sshd start_desktop +start_guestd while true; do if ! pid_running "${ready_agent_pid:-}"; then @@ -139,5 +148,9 @@ while true; do log "desktop session exited; restarting" start_desktop fi + if ! pid_running "${guestd_pid:-}"; then + log "guestd exited; restarting" + start_guestd + fi sleep 1 done