| 1 | import * as AWS from "alchemy/AWS"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import { MicrovmBuildRole } from "./build-role.ts"; |
| 4 | |
| 5 | /** |
| 6 | * Bun baseline MicroVM image — the dumbest possible `Bun.serve` HTTP server, |
| 7 | * built from `contexts/microvm-bun/` the same way alchemy builds the effectful |
| 8 | * {@link import("./effectful-bun.ts").EffectfulBun} image (same MicroVM base, same bun install, same ARM_64 arch, |
| 9 | * same 512 MiB). The only difference is the absence of the Effect runtime and |
| 10 | * the alchemy bootstrap, so `effectful.readyMs − bun.readyMs` isolates the |
| 11 | * cold-start cost of alchemy's Effect abstraction with the runtime and CPU |
| 12 | * architecture held constant. |
| 13 | */ |
| 14 | export class BunMicrovm extends AWS.Lambda.MicrovmImage<BunMicrovm>()( |
| 15 | "MicrovmBenchBun", |
| 16 | ) {} |
| 17 | |
| 18 | export default BunMicrovm.make( |
| 19 | MicrovmBuildRole.pipe( |
| 20 | Effect.map((buildRole) => ({ |
| 21 | // External (Dockerfile) mode: the runtime is NOT chosen by alchemy's |
| 22 | // `runtime` prop (that only applies to effectful `main:` images). It is |
| 23 | // decided entirely by this context's Dockerfile, which installs and runs |
| 24 | // bun. Match the effectful EffectfulBun's image config: ARM_64, 512 MiB. |
| 25 | context: new URL("../contexts/microvm-bun/", import.meta.url).pathname, |
| 26 | buildRole, |
| 27 | resources: [{ minimumMemoryInMiB: 512 }], |
| 28 | cpuConfigurations: [{ architecture: "ARM_64" }], |
| 29 | })), |
| 30 | ), |
| 31 | // External (Dockerfile) mode — no Effect runtime to bundle. |
| 32 | Effect.succeed({}), |
| 33 | ); |