1import * as AWS from "alchemy/AWS";
2import * as Effect from "effect/Effect";
3import { MicrovmBuildRole } from "./build-role.ts";
4
5/**
6 * Node baseline MicroVM image — the dumbest possible `http.createServer`
7 * server, built from `contexts/microvm-node/` the same way alchemy builds the
8 * effectful node {@link import("./effectful-node.ts").EffectfulNode} image (same
9 * MicroVM base, same `dnf install -y nodejs`, same ARM_64 arch, same 512 MiB).
10 * `effectfulNode.readyMs − node.readyMs` isolates the alchemy/Effect cold-start
11 * tax on the runtime the Lambda VMs already ship.
12 */
13export class NodeMicrovm extends AWS.Lambda.MicrovmImage<NodeMicrovm>()(
14 "MicrovmBenchNode",
15) {}
16
17export default NodeMicrovm.make(
18 MicrovmBuildRole.pipe(
19 Effect.map((buildRole) => ({
20 // External (Dockerfile) mode: the runtime is decided by this context's
21 // Dockerfile (installs + runs node), NOT by alchemy's `runtime` prop —
22 // that only applies to effectful `main:` images. Match the effectful
23 // EffectfulNode's image config: ARM_64, 512 MiB.
24 context: new URL("../contexts/microvm-node/", import.meta.url).pathname,
25 buildRole,
26 resources: [{ minimumMemoryInMiB: 512 }],
27 cpuConfigurations: [{ architecture: "ARM_64" }],
28 })),
29 ),
30 // External (Dockerfile) mode — no Effect runtime to bundle.
31 Effect.succeed({}),
32);