Merge pull request 'Fix BW Manager deploy staging argv limit' (#18) from fix/bw-deploy-argv-20260812 into main
This commit is contained in:
commit
e600fada5a
1 changed files with 14 additions and 7 deletions
21
app.py
21
app.py
|
|
@ -1210,21 +1210,28 @@ def _deploy_bw_manager_compose(files: dict[str, str]) -> dict:
|
|||
backup = f"/app-config/deployment-backups/bw-manager-{timestamp}"
|
||||
image = "bw-manager-bw-manager"
|
||||
rollback_image = f"{image}:rollback-{timestamp}"
|
||||
script = f"""from pathlib import Path
|
||||
init_script = f"""from pathlib import Path
|
||||
import shutil
|
||||
candidate = Path({candidate!r})
|
||||
if candidate.exists(): shutil.rmtree(candidate)
|
||||
candidate.mkdir(parents=True)
|
||||
for relative, content in {files!r}.items():
|
||||
target = candidate / relative
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_text(content)
|
||||
live_env = Path({working_dir!r}) / '.env'
|
||||
if live_env.exists(): shutil.copy2(live_env, candidate / '.env')
|
||||
"""
|
||||
rc, _out, err = _remote_python(script)
|
||||
rc, _out, err = _remote_python(init_script)
|
||||
if rc != 0:
|
||||
raise RuntimeError(f"BW Manager candidate staging failed: {err[-300:]}")
|
||||
raise RuntimeError(f"BW Manager candidate initialization failed: {err[-300:]}")
|
||||
# Stage one file per SSH call. Sending the complete repository in one
|
||||
# command exceeds Linux's argv limit once app.py and templates are encoded.
|
||||
for relative, content in files.items():
|
||||
file_script = f"""from pathlib import Path
|
||||
target = Path({candidate!r}) / {relative!r}
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_text({content!r})
|
||||
"""
|
||||
rc, _out, err = _remote_python(file_script)
|
||||
if rc != 0:
|
||||
raise RuntimeError(f"BW Manager staging failed for {relative}: {err[-300:]}")
|
||||
rc, _out, err = _ssh(VPS_SSH, f"cd {candidate} && docker compose config -q && docker compose build --pull", timeout=600)
|
||||
if rc != 0:
|
||||
raise RuntimeError(f"BW Manager candidate build failed: {err[-500:]}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue