Skip to content

Commit 6ce69b4

Browse files
committed
feat: dev/main config profiles with branch override [skip-version]
- Add lpb.stack.dev.env and lpb.stack.main.env profiles - lpb --tag dev → LPB_PI_REF=lpb-dev, LPB_CONFIG_REF=dev - lpb --tag main → LPB_PI_REF=lpb, LPB_CONFIG_REF=main - lpb --tag latest → same as main - lpb --tag <custom> → no overrides (uses defaults) - Fix start.sh to respect runtime env overrides (LPB_PI_REF, LPB_CONFIG_REF) instead of overwriting with baked-in values
1 parent 4fb7914 commit 6ce69b4

4 files changed

Lines changed: 59 additions & 0 deletions

File tree

‎lpb.stack.dev.env‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# lpb.stack.dev.env — Dev profile configuration
2+
#
3+
# Points to development branches for testing.
4+
# Used when running: lpb --tag dev
5+
6+
# ─── Pi Monorepo ────────────────────────────────────────────────────────
7+
LPB_PI_REF=lpb-dev
8+
9+
# ─── Config Preset ───────────────────────────────────────────────────────
10+
LPB_CONFIG_REF=dev

‎lpb.stack.main.env‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# lpb.stack.main.env — Main profile configuration
2+
#
3+
# Points to stable branches (lpb + main).
4+
# Used when running: lpb --tag main or lpb --tag latest
5+
6+
# ─── Pi Monorepo ────────────────────────────────────────────────────────
7+
# Use 'lpb' branch (stable base) for main pipeline.
8+
LPB_PI_REF=lpb
9+
10+
# ─── Config Preset ───────────────────────────────────────────────────────
11+
LPB_CONFIG_REF=main

‎scripts/lpb.py‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,27 @@ def resolve_web_image(tag: str) -> str:
161161
return WEB_IMAGE
162162

163163

164+
# ─── Config profile selection (dev vs main) ───────────────────────────
165+
# When --tag dev or --tag main is used, override LPB_PI_REF and
166+
# LPB_CONFIG_REF to point to the appropriate branches.
167+
def _resolve_config_profile(tag: str) -> dict[str, str] | None:
168+
"""Return config overrides based on image tag.
169+
170+
Returns None for custom tags (e.g. mybranch, sha).
171+
172+
Branch mapping:
173+
--tag dev → LPB_PI_REF=lpb-dev, LPB_CONFIG_REF=dev
174+
--tag main → LPB_PI_REF=lpb, LPB_CONFIG_REF=main
175+
--tag latest → LPB_PI_REF=lpb, LPB_CONFIG_REF=main (same as main)
176+
--tag <x> → no overrides (custom/PR images use defaults)
177+
"""
178+
if tag == "dev":
179+
return {"LPB_PI_REF": "lpb-dev", "LPB_CONFIG_REF": "dev"}
180+
elif tag == "main" or tag == "latest":
181+
return {"LPB_PI_REF": "lpb", "LPB_CONFIG_REF": "main"}
182+
return None
183+
184+
164185
# ─── Load runtime configuration ──────────────────────────────────────────
165186
# lpb.conf.env defines runtime defaults (editor, browser, LLM, persistence)
166187
# Loaded after stack env — workspace .env overrides both.
@@ -1087,12 +1108,23 @@ def cmd_run():
10871108
# Resolve a stable connection token (generate+persist if unset) so the URL
10881109
# lpb prints matches the token the VSCodium server actually enforces.
10891110
ensure_token()
1111+
1112+
# Apply config profile overrides (dev/main branch selection)
1113+
profile = _resolve_config_profile(tag)
1114+
if profile:
1115+
info(f" Config: {tag} profile (LPB_PI_REF={profile['LPB_PI_REF']}, LPB_CONFIG_REF={profile['LPB_CONFIG_REF']})")
1116+
else:
1117+
info(f" Config: custom (using defaults)")
1118+
10901119
env_vars = [
10911120
f"LPB_ED_PORT={cfg.port}",
10921121
f"LPB_EDITOR_HOST={cfg.host}",
10931122
f"LPB_DEVCONTAINER_WORKSPACE_DIR={mount_path}",
10941123
f"LPB_CONNECTION_TOKEN={cfg.token}",
10951124
f"CONNECTION_TOKEN={cfg.token}",
1125+
# Config profile overrides (applied based on --tag)
1126+
f"LPB_PI_REF={profile['LPB_PI_REF']}" if profile else "",
1127+
f"LPB_CONFIG_REF={profile['LPB_CONFIG_REF']}" if profile else "",
10961128
# Note: LPB_STATE_DIR is NOT passed to the container. It's a launcher-time
10971129
# config (lpb.py reads it to resolve the host mount source). The container
10981130
# has no need for it — start.sh uses its own defaults. Passing it here

‎support/start.sh‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,16 @@ fi
7373

7474
# Stack identity (image names, forks, versions) — baked at build time.
7575
# Provides LPB_CONFIG_FORK / LPB_CONFIG_REF defaults for the clone below.
76+
# NOTE: Runtime env vars (-e from lpb.py) take precedence over baked values.
7677
_stack_env="/opt/devstack/lpb.stack.env"
7778
if [[ -f "${_stack_env}" ]]; then
7879
debug "Loading build identity from ${_stack_env}"
7980
while IFS= read -r _line; do
81+
# Skip lines where the env var is already set (runtime override)
82+
_key="${_line%%=*}"
83+
if [[ -n "${!_key+x}" ]]; then
84+
continue
85+
fi
8086
export "$_line"
8187
done < <(parse_env_file "${_stack_env}")
8288
fi

0 commit comments

Comments
 (0)