Next.js with Bun
This variant uses the oven/bun:1.3 image and installs the same pinned Next.js dependencies with Bun. The development server listens on port 3000.
mjs
import { Sandbox, Template, waitForURL } from "@abox-dev/sdk";
const templateName = process.env.TEMPLATE_NAME ?? "nextjs-bun-app";
const template = Template({ fileContextPath: "." })
.fromBunImage("1.3")
.setWorkdir("/home/user/app")
.copy("package.json", "/home/user/app/package.json")
.copy("app", "/home/user/app/app")
.runCmd("bun install")
.setStartCmd(
"bun run dev --hostname 0.0.0.0",
waitForURL("http://localhost:3000"),
);
await Template.build(template, templateName, {
cpuCount: 2,
memoryMB: 2_048,
});
const sandbox = await Sandbox.create(templateName);
try {
const page = await sandbox.commands.run(
"curl --silent http://localhost:3000",
);
console.log(page.stdout);
} finally {
await sandbox.kill();
}Keep package.json, app/layout.jsx, and app/page.jsx next to the example. Rebuild the template after dependency changes. Page-only changes can keep the existing bun install layer.