worker: bake dotfiles pi config (filtered) + shared lvmh-pi-cache volume; CopyToContainer seeding
This commit is contained in:
@@ -7,3 +7,4 @@ daemon/.pi-scratch/
|
|||||||
coverage
|
coverage
|
||||||
daemon/lvmh-daemon
|
daemon/lvmh-daemon
|
||||||
e2e-integration-report.md
|
e2e-integration-report.md
|
||||||
|
docker/pi-agent/
|
||||||
|
|||||||
+10
-1
@@ -41,6 +41,8 @@ const (
|
|||||||
labelSession string = "lvmh.session"
|
labelSession string = "lvmh.session"
|
||||||
volumeRepoPrefix string = "lvmh-repo-"
|
volumeRepoPrefix string = "lvmh-repo-"
|
||||||
volumeSessions string = "lvmh-sessions"
|
volumeSessions string = "lvmh-sessions"
|
||||||
|
volumePiCache string = "lvmh-pi-cache" // pi package cache (git:/npm:), shared across spawns
|
||||||
|
cacheMount string = "/root/.pi/agent/cache"
|
||||||
workspaceMount string = "/workspace"
|
workspaceMount string = "/workspace"
|
||||||
sessionsMount string = "/pi-sessions"
|
sessionsMount string = "/pi-sessions"
|
||||||
|
|
||||||
@@ -382,8 +384,15 @@ func (s *Spawner) createAndStart(ctx context.Context, repo, slug, sessionID stri
|
|||||||
if _, err := s.cli.VolumeCreate(ctx, volume.CreateOptions{Name: volumeSessions}); err != nil {
|
if _, err := s.cli.VolumeCreate(ctx, volume.CreateOptions{Name: volumeSessions}); err != nil {
|
||||||
return "", fmt.Errorf("volume %s: %w", volumeSessions, err)
|
return "", fmt.Errorf("volume %s: %w", volumeSessions, err)
|
||||||
}
|
}
|
||||||
|
if _, err := s.cli.VolumeCreate(ctx, volume.CreateOptions{Name: volumePiCache}); err != nil {
|
||||||
|
return "", fmt.Errorf("volume %s: %w", volumePiCache, err)
|
||||||
|
}
|
||||||
|
|
||||||
binds := []string{repoVolume + ":" + workspaceMount, volumeSessions + ":" + sessionsMount}
|
binds := []string{
|
||||||
|
repoVolume + ":" + workspaceMount,
|
||||||
|
volumeSessions + ":" + sessionsMount,
|
||||||
|
volumePiCache + ":" + cacheMount,
|
||||||
|
}
|
||||||
cfg := &container.Config{
|
cfg := &container.Config{
|
||||||
Image: imageRefWorker,
|
Image: imageRefWorker,
|
||||||
Env: []string{
|
Env: []string{
|
||||||
|
|||||||
@@ -77,9 +77,10 @@ func TestSpawnerStartHappyPath(t *testing.T) {
|
|||||||
wantBinds := []string{
|
wantBinds := []string{
|
||||||
"lvmh-repo-group-project:" + workspaceMount,
|
"lvmh-repo-group-project:" + workspaceMount,
|
||||||
volumeSessions + ":" + sessionsMount,
|
volumeSessions + ":" + sessionsMount,
|
||||||
|
volumePiCache + ":" + cacheMount,
|
||||||
}
|
}
|
||||||
if len(c.HostConfig.Binds) != 2 {
|
if len(c.HostConfig.Binds) != 3 {
|
||||||
t.Fatalf("binds = %v, want %v (no models file)", c.HostConfig.Binds, wantBinds)
|
t.Fatalf("binds = %v, want %v", c.HostConfig.Binds, wantBinds)
|
||||||
}
|
}
|
||||||
for i, b := range wantBinds {
|
for i, b := range wantBinds {
|
||||||
if c.HostConfig.Binds[i] != b {
|
if c.HostConfig.Binds[i] != b {
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ if [ ! -f web/dist/index.html ]; then
|
|||||||
(cd web && bun install && bun run build)
|
(cd web && bun install && bun run build)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Bake the user's pi config (dotfiles) into the worker image context.
|
||||||
|
bash "$(dirname "$0")/rsync-pi-agent.sh"
|
||||||
|
|
||||||
rsync -az --delete \
|
rsync -az --delete \
|
||||||
--exclude .git --exclude node_modules --exclude web/node_modules \
|
--exclude .git --exclude node_modules --exclude web/node_modules \
|
||||||
--exclude .env --exclude .scratch --exclude .pi --exclude coverage \
|
--exclude .env --exclude .scratch --exclude .pi --exclude coverage \
|
||||||
|
|||||||
Executable
+31
@@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Sync the user's pi config (from dotfiles) into docker/pi-agent/ so the
|
||||||
|
# worker image bakes it. Filtered: no secrets, no machine-local state.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SRC="${LVMH_PI_AGENT_DIR:-$HOME/.dotfiles/pi/agent}"
|
||||||
|
DEST="$(dirname "$0")/../docker/pi-agent"
|
||||||
|
|
||||||
|
if [ ! -f "$SRC/settings.json" ]; then
|
||||||
|
echo "rsync-pi-agent: $SRC/settings.json not found — skipping dotfiles sync" >&2
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$DEST"
|
||||||
|
rsync -a --delete \
|
||||||
|
--exclude 'auth.json' \
|
||||||
|
--exclude 'models.json' \
|
||||||
|
--exclude 'models-store.json' \
|
||||||
|
--exclude 'sessions/' \
|
||||||
|
--exclude 'cache/' \
|
||||||
|
--exclude 'npm/' \
|
||||||
|
--exclude 'git/' \
|
||||||
|
--exclude 'trust.json' \
|
||||||
|
--exclude 'mcp-*' \
|
||||||
|
--exclude 'run-history*' \
|
||||||
|
--exclude 'vibes/' \
|
||||||
|
--exclude '*.log' \
|
||||||
|
--exclude 'scratch/' \
|
||||||
|
--exclude '.pi/' \
|
||||||
|
"$SRC/" "$DEST/"
|
||||||
|
echo "rsync-pi-agent: synced $(find "$DEST" -type f | wc -l) files from $SRC"
|
||||||
@@ -11,12 +11,19 @@ RUN apt-get update \
|
|||||||
|
|
||||||
RUN npm install -g --ignore-scripts @earendil-works/pi-coding-agent
|
RUN npm install -g --ignore-scripts @earendil-works/pi-coding-agent
|
||||||
|
|
||||||
# lvmh plugin: dial-home mirror (built from plugin/ at repo root)
|
# User's pi config from dotfiles (settings, skills, agents, extensions,
|
||||||
|
# APPEND_SYSTEM.md) — synced by deploy.sh from ~/.dotfiles/pi/agent (filtered:
|
||||||
|
# no auth.json/sessions/cache/npm). If docker/pi-agent/ is absent this layer
|
||||||
|
# is skipped (mkdir keeps later COPY targets valid).
|
||||||
|
COPY docker/pi-agent/ /root/.pi/agent/
|
||||||
|
|
||||||
|
# lvmh overlays: dial-home plugin + env-ref models.json win over dotfiles copies.
|
||||||
COPY plugin/lvmh-agent.ts /root/.pi/agent/extensions/lvmh-agent.ts
|
COPY plugin/lvmh-agent.ts /root/.pi/agent/extensions/lvmh-agent.ts
|
||||||
COPY docker/worker-models.json /root/.pi/agent/models.json
|
COPY docker/worker-models.json /root/.pi/agent/models.json
|
||||||
COPY docker/bridge /bridge
|
COPY docker/bridge /bridge
|
||||||
|
|
||||||
# Per-session pi sessions persist here (volume lvmh-sessions)
|
# Per-session pi sessions persist here (volume lvmh-sessions); package cache
|
||||||
|
# shared across spawns via volume lvmh-pi-cache at /root/.pi/agent/cache.
|
||||||
ENV PI_SESSION_DIR=/pi-sessions
|
ENV PI_SESSION_DIR=/pi-sessions
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
CMD ["node", "/bridge/index.mjs"]
|
CMD ["node", "/bridge/index.mjs"]
|
||||||
|
|||||||
Reference in New Issue
Block a user