Docker SBX pi.dev rust sandbox
1.0K
This is an example of a custom Docker SBX Template and Kit for providing a customized sandbox for Rust development using pi.dev.
It consists of
Dockerfile
FROM docker/sandbox-templates:shell
USER root
### Ubuntu Packages ###
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \
build-essential \
fd-find \
ripgrep \
curl \
btop \
git \
vim \
nodejs \
npm \
golang-go \
python3 \
python3-pip \
python3-venv \
mingw-w64 \
clang \
lld \
llvm \
&& /usr/bin/ln -sf /usr/bin/fdfind /usr/local/bin/fd \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
### UV ###
ENV UV_INSTALL_DIR=/usr/local/bin
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
WORKDIR /home/agent
USER agent
### Rust ###
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN /home/agent/.cargo/bin/rustup target add \
x86_64-unknown-linux-gnu \
x86_64-pc-windows-gnu \
x86_64-pc-windows-msvc \
wasm32-unknown-unknown \
wasm32-wasip1 && \
/home/agent/.cargo/bin/rustup component add rustfmt clippy rust-analyzer rust-src && \
/home/agent/.cargo/bin/rustup set default-host x86_64-unknown-linux-gnu
### Pi.Dev ###
RUN npm install -g --ignore-scripts @earendil-works/pi-coding-agent
### Semble ###
RUN /usr/local/bin/uv tool install semble
### CodeGraph ###
RUN /usr/bin/npm install -g @colbymchenry/codegraph
### Amend PATH
ENV PATH="/home/agent/.local:$PATH"
ENV PATH="/home/agent/.local/bin:$PATH"
ENV PATH="/home/agent/.cargo/bin:$PATH"
ENTRYPOINT ["pi"]
build.ps1
$MyTag = Get-Date -Format "yyyyMMddHHmm"
docker buildx build --no-cache --platform linux/amd64 -t freecoderhub/sbx-pi-rust:$MyTag -t freecoderhub/sbx-pi-rust:latest --push .
build.cmd
powershell -ExecutionPolicy Bypass -File .\build.ps1
spec.yaml
schemaVersion: "2"
kind: sandbox
name: sbx-pi-rust-agent
network:
allowedDomains:
- "*"
sandbox:
image: "docker.io/freecoderhub/sbx-pi-rust:latest"
entrypoint:
run: ["pi"]
agentContext:
## Sandbox environment
Inside Docker sandbox. `sudo` is passwordless for package installs.
commands:
install:
- description: "Update Installation"
user: "0"
command: ( /usr/bin/apt-get update && /usr/bin/apt-get upgrade -y ) > /tmp/update_ubuntu.txt 2>&1
- description: "Update Rust"
user: "1000"
command: /home/agent/.cargo/bin/rustup update > /tmp/update_rust.txt 2>&1
- description: "Update Pi"
user: "1000"
command: /usr/bin/npm update -g @earendil-works/pi-coding-agent > /tmp/update_pi.txt 2>&1
- description: "Update sandbox persistence"
user: "0"
command: |
cat << 'FEOF' >> /etc/sandbox-persistent.sh
export PATH="$HOME/.local:$PATH"
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/.cargo/bin:$PATH"
FEOF
run.cmd
@echo off
set "script_dir=%~dp0"
for %%I in ("%~dp0..") do set "working_dir=%%~fI"
sbx run --kit %script_dir% --name sbx-pi-rust-sandbox sbx-pi-rust-agent %working_dir%
sbx rm --force sbx-pi-rust-sandbox
Content type
Image
Digest
sha256:2bd09e1dc…
Size
3.7 GB
Last updated
about 1 month ago
docker pull freecoderhub/sbx-pi-rust