Open History to see the last commit
1import * as AWS from "@alchemy.run/aws";
2import * as Effect from "effect/Effect";
3import { MicrovmBuildRole } from "./build-role.ts";
4
5/**
6 * MicroVM image running an eagerly-started opencode server (a real coding
7 * agent, ~100 MB binary on a Bun runtime). The Dockerfile's ENTRYPOINT is
8 * `opencode serve`; the MicroVM image build runs it and snapshots the running
9 * memory+disk, so every `RunMicrovm` resumes from a snapshot where the server
10 * is ALREADY listening — the process startup cost is paid once at build time,
11 * not on each boot. Compare with the Cloudflare
12 * {@link import("./opencode-container.ts").OpencodeContainer}, which starts
13 * the same image's entrypoint from scratch on every cold start.
14 */
15export class OpencodeMicrovm extends AWS.Lambda.MicrovmImage<OpencodeMicrovm>()(
16 "MicrovmBenchOpencode",
17) {}
18
19export default OpencodeMicrovm.make(
20 MicrovmBuildRole.pipe(
21 Effect.map((buildRole) => ({
22 context: new URL("../contexts/microvm-opencode/", import.meta.url).pathname,
23 buildRole,
24 // opencode is heavier than the hello-world servers; give it 1 GiB
25 // (matching the Cloudflare variant's tier as closely as the two
26 // platforms' sizing knobs allow).
27 resources: [{ minimumMemoryInMiB: 1024 }],
28 cpuConfigurations: [{ architecture: "ARM_64" }],
29 })),
30 ),
31 // Built from the Dockerfile; no Effect program is bundled.
32 Effect.succeed({}),
33);