MCPcopy Create free account
hub / github.com/cloudflare/computer / ensureImage

Function ensureImage

script/computerd-soak.mjs:70–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68}
69
70async function ensureImage() {
71 try {
72 await execFileP("docker", ["image", "inspect", IMAGE_TAG]);
73 return;
74 } catch {
75 // build it
76 }
77 process.stderr.write(`building ${IMAGE_TAG}...\n`);
78 const proc = spawn("docker", ["build", "--platform", "linux/amd64", "-t", IMAGE_TAG, "-"], {
79 stdio: ["pipe", "inherit", "inherit"],
80 });
81 proc.stdin.end(
82 `FROM --platform=linux/amd64 debian:stable-slim
83RUN apt-get update >/dev/null && apt-get install -y --no-install-recommends \\
84 fuse3 libfuse2t64 attr util-linux coreutils findutils \\
85 >/dev/null && rm -rf /var/lib/apt/lists/*
86`,
87 );
88 await new Promise((res, rej) => {
89 proc.on("exit", (code) => (code === 0 ? res() : rej(new Error(`docker build exit ${code}`))));
90 });
91}
92
93async function bootContainer(extraEnv = {}) {
94 const args = ["run", "--rm", "-d", "--platform", "linux/amd64"];

Callers 1

mainFunction · 0.85

Calls 2

writeMethod · 0.65
endMethod · 0.65

Tested by

no test coverage detected