Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions envs/pi_env/hf_image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ RUN apt-get update \
# Proxy deps that interception.py imports.
RUN pip install --no-cache-dir "fastapi>=0.104" "uvicorn[standard]>=0.24" "httpx>=0.27"

# Pi's launcher uses `#!/usr/bin/env node`; keep both pre-baked tools available
# while building the image and when the sandbox executes Pi at runtime.
ENV PATH="/root/.node/bin:/root/.pi-npm/bin:${PATH}"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct placement. Pi's launcher shebang is #!/usr/bin/env node, so this makes env node resolve to the pre-baked /root/.node/bin/node both during the build (the pi --version check below) and at container runtime. Declaring it before the install RUN is fine even though /root/.node / /root/.pi-npm don't exist yet — PATH is resolved at command-exec time, by which point the RUN has created them. ${PATH} expands from the base image's PATH as expected.


# Node 22 (pi requires >=22.19) + the pi CLI, at the paths pi_runtime expects.
RUN A=$(uname -m); case $A in x86_64) A=x64;; aarch64|arm64) A=arm64;; esac \
&& curl -fsSL "https://nodejs.org/dist/v22.19.0/node-v22.19.0-linux-$A.tar.xz" | tar -xJ -C /root \
Expand Down
10 changes: 10 additions & 0 deletions tests/envs/test_pi_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ def test_install_cmd_bootstraps_node_and_installs_pi():
assert cmd.strip().endswith("/root/.pi-npm/bin/pi --version")


def test_hf_image_exposes_node_and_pi_on_path():
dockerfile = os.path.join(_REPO_ROOT, "envs", "pi_env", "hf_image", "Dockerfile")
with open(dockerfile, encoding="utf-8") as stream:
contents = stream.read()

path_env = 'ENV PATH="/root/.node/bin:/root/.pi-npm/bin:${PATH}"'
assert path_env in contents
assert contents.index(path_env) < contents.index("# Node 22")


def test_install_cmd_pins_version():
cmd = rt.build_install_cmd(_cfg(pi_version="0.73.0"))
assert "@mariozechner/pi-coding-agent@0.73.0" in cmd
Expand Down