Skip to content

Commit a232b96

Browse files
committed
Fix Dockerfile build issues + validate config-dir-to-repo setup
Dockerfile: - Remove redundant /opt/pi-support/lpb-config copy (unused, non-executable) - Create /home/lpb/.agent-browser/sessions before chown (was failing: chown -R on a non-existent path) - Use COPY --chmod=755 for entrypoint-web.sh (no reliance on USER root) start.sh: - Move config repo clone/fetch OUT of FIRST_RUN block into a new every-boot §4a section, so PI_CODING_AGENT_DIR is exported before pi launches on every boot (not just first run). Non-destructive fetch preserves local customizations; use lpb-config for updates. lpb-config: - Fix positional-arg collision: $1 was both the subcommand and AGENT_DIR. The repo path/remote/ref now come from env vars only (matching the documented interface), which broke status/update/reset/merge.
1 parent 1319004 commit a232b96

3 files changed

Lines changed: 34 additions & 27 deletions

File tree

Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ COPY support/validate-subagent-output.ts /opt/pi-support/validate-subagent-outpu
141141
COPY support/config/ /opt/pi-support/config/
142142
COPY support/docs/ /opt/pi-support/docs/
143143
COPY support/schemas/ /opt/pi-support/schemas/
144-
COPY support/lpb-config /opt/pi-support/lpb-config
145144

146145
# ── Devstack deployment scripts ──
147146
COPY --chmod=755 support/install-browser.sh /opt/devstack/install-browser.sh
@@ -157,7 +156,8 @@ COPY --chmod=755 support/lpb-config /home/lpb/.local/bin/lpb-config
157156

158157
# ─── Ownership (must run as root — COPY creates files as root) ───────────
159158
USER root
160-
RUN chown -R 1000:1000 /home/lpb /opt/devstack /opt/pi-support /home/lpb/.agent-browser
159+
RUN mkdir -p /home/lpb/.agent-browser/sessions \
160+
&& chown -R 1000:1000 /home/lpb /opt/devstack /opt/pi-support
161161
USER lpb
162162

163163
# ─── Git credential helper ────────────────────────────────────────────
@@ -222,8 +222,7 @@ RUN set -eux; \
222222
install_ext pi0 pi-vscode || echo "WARN: pi-vscode install failed"; \
223223
chown -R 1000:1000 /home/lpb/.vscodium-server
224224

225-
COPY support/entrypoint-web.sh /opt/devstack/entrypoint-web.sh
226-
RUN chmod +x /opt/devstack/entrypoint-web.sh
225+
COPY --chmod=755 support/entrypoint-web.sh /opt/devstack/entrypoint-web.sh
227226

228227
RUN chown -R 1000:1000 /home/lpb
229228

support/lpb-config

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99

1010
set -euo pipefail
1111

12-
AGENT_DIR="${1:-/home/lpb/.pi}"
13-
CONFIG_REMOTE="${2:-https://github.com/localpibox/config.git}"
14-
CONFIG_REF="${3:-main}"
12+
# Config repo location — override via env vars (see help below).
13+
# NOTE: positionals are reserved for the subcommand ($1), so the
14+
# repo path/remote/ref come from the environment, not $1/$2/$3.
15+
AGENT_DIR="${AGENT_DIR:-/home/lpb/.pi}"
16+
CONFIG_REMOTE="${CONFIG_REMOTE:-https://github.com/localpibox/config.git}"
17+
CONFIG_REF="${CONFIG_REF:-main}"
1518

1619
# ─── Helpers ────────────────────────────────────────────────────────────────
1720
info() { echo "[lpb-config] $*"; }

support/start.sh

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -260,26 +260,7 @@ with open(sys.argv[1], 'w') as f: json.dump(pkg, f, indent=2)
260260
info "Patched pi-coding-agent package.json with allowScripts."
261261
fi
262262

263-
# ── Config repo: clone/fetch into ~/.pi/ directly ──────────────────────
264-
# The config repo IS the runtime directory (~/.pi/). No copy step needed.
265-
# start.sh ensures the repo is cloned on first run and fetched on every boot.
266-
AGENT_DIR="${HOME_DIR}/.pi"
267-
CONFIG_REMOTE="${LPB_CONFIG_REMOTE:-https://github.com/localpibox/config.git}"
268-
CONFIG_REF="${LPB_CONFIG_REF:-main}"
269-
270-
if [[ ! -d "${AGENT_DIR}/.git" ]]; then
271-
info "Cloning config repo from ${CONFIG_REMOTE} (first run)..."
272-
git clone --depth=1 --branch "${CONFIG_REF}" "${CONFIG_REMOTE}" "${AGENT_DIR}"
273-
else
274-
info "Fetching config repo updates..."
275-
git -C "${AGENT_DIR}" fetch origin "${CONFIG_REF}" 2>/dev/null || true
276-
fi
277-
278-
# ── Tell Pi to read config from ~/.pi/ (config repo root) ────────────
279-
# Pi defaults to ~/.pi/agent/, but our config repo IS ~/.pi/.
280-
# This env var is picked up by Pi at startup.
281-
export PI_CODING_AGENT_DIR="${AGENT_DIR}"
282-
263+
# ── Config repo: clone/fetch into ~/.pi/ (runs every boot — see §4a) ──
283264
touch "${HOME_DIR}/.pi/.initialized"
284265

285266
# ── Unlock the user account with a random password ──────────────────
@@ -310,6 +291,30 @@ with open(sys.argv[1], 'w') as f: json.dump(pkg, f, indent=2)
310291
info "First run bootstrap complete."
311292
fi
312293

294+
# ─── 4a. CONFIG REPO — CLONE/FETCH INTO ~/.pi/ (EVERY BOOT) ────────────────
295+
# The config repo (localpibox/config) IS the runtime config directory (~/.pi/).
296+
# No copy step — Pi reads the repo root directly via PI_CODING_AGENT_DIR.
297+
# Runs on every boot: clones on first run, fetches (non-destructive) after.
298+
AGENT_DIR="${HOME_DIR}/.pi"
299+
CONFIG_REMOTE="${LPB_CONFIG_REMOTE:-https://github.com/localpibox/config.git}"
300+
CONFIG_REF="${LPB_CONFIG_REF:-main}"
301+
302+
export PI_CODING_AGENT_DIR="${AGENT_DIR}"
303+
304+
if [[ ! -d "${AGENT_DIR}/.git" ]]; then
305+
info "Cloning config repo from ${CONFIG_REMOTE}..."
306+
if git clone --depth=1 --branch "${CONFIG_REF}" "${CONFIG_REMOTE}" "${AGENT_DIR}"; then
307+
info "Config repo cloned."
308+
else
309+
warn "Config clone failed — Pi will use defaults."
310+
fi
311+
else
312+
# Non-destructive fetch only — local customizations are never wiped.
313+
# Use 'lpb-config update/reset/merge' for actual updates.
314+
git -C "${AGENT_DIR}" fetch origin "${CONFIG_REF}" 2>/dev/null || true
315+
debug "Config repo fetched (manual update via lpb-config)."
316+
fi
317+
313318
# ─── 4b. ENSURE HOME MOUNT PARENTS ARE WRITABLE (EVERY BOOT) ────────────────
314319
# The container runtime recreates host-volume bind-mount parents (e.g.
315320
# /home/lpb/.config for the gh-config mount) as root on boot, so a directory

0 commit comments

Comments
 (0)