The base template is a minimal Ubuntu 22.04 image with git, curl,
wget, jq, build-essential, openssh-client, and unzip. Pick it
when you only need shell utilities or want the smallest possible image to
install your own toolchain on top of.
What you’ll learn
- Picking
template="base" for shell-only workloads
- Running a multi-tool pipeline (
curl → jq) inside a sandbox
- Inspecting what ships in the
base image with which / --version
Prerequisites
export DECLAW_API_KEY="your-api-key"
export DECLAW_DOMAIN="your-declaw-instance.example.com:8080"
Code
from declaw import Sandbox
def main() -> None:
sbx = Sandbox.create(template="base", timeout=120)
try:
# 1. Confirm what's preinstalled.
for tool in ("git", "curl", "jq", "wget"):
r = sbx.commands.run(f"{tool} --version")
first_line = (r.stdout or r.stderr).splitlines()[0]
print(f"{tool}: {first_line}")
# 2. Use them together: clone a tiny repo, then list files.
r = sbx.commands.run(
"cd /tmp && "
"git clone --depth 1 https://github.com/jqlang/jq.git jq-src && "
"ls jq-src | head -5"
)
print("\nclone output:")
print(r.stdout)
# 3. curl + jq pipeline against a public JSON endpoint.
r = sbx.commands.run(
'curl -s https://api.github.com/repos/jqlang/jq '
'| jq "{name: .name, stars: .stargazers_count, language: .language}"'
)
print("repo summary:")
print(r.stdout)
finally:
sbx.kill()
if __name__ == "__main__":
main()
import "dotenv/config";
import { Sandbox } from "@declaw/sdk";
async function main(): Promise<void> {
const sbx = await Sandbox.create({ template: "base", timeout: 120 });
try {
for (const tool of ["git", "curl", "jq", "wget"]) {
const r = await sbx.commands.run(`${tool} --version`);
const firstLine = (r.stdout || r.stderr).split("\n")[0];
console.log(`${tool}: ${firstLine}`);
}
let r = await sbx.commands.run(
"cd /tmp && " +
"git clone --depth 1 https://github.com/jqlang/jq.git jq-src && " +
"ls jq-src | head -5",
);
console.log("\nclone output:");
console.log(r.stdout);
r = await sbx.commands.run(
"curl -s https://api.github.com/repos/jqlang/jq " +
'| jq "{name: .name, stars: .stargazers_count, language: .language}"',
);
console.log("repo summary:");
console.log(r.stdout);
} finally {
await sbx.kill();
}
}
main().catch(console.error);
Expected output
git: git version 2.34.1
curl: curl 7.81.0 (x86_64-pc-linux-gnu) ...
jq: jq-1.6
wget: GNU Wget 1.21.2 ...
clone output:
AUTHORS
COPYING
ChangeLog
Makefile.am
README.md
repo summary:
{
"name": "jq",
"stars": 30000,
"language": "C"
}
base does not ship Python or Node. If you apt-get install python3 at
runtime it will work, but you’ll wait for the install on every sandbox boot
— picking template="python" or template="node" is faster.