# Build and Test Environments

{/* vale off */}

Give every build or test job its own microVM. Start your full toolchain from a [snapshot](/features/snapshots) in milliseconds, and inject that job's code at boot time.

<ValueCards>
  <ValueCard title="Start chunky environments fast" metric="boots in < 10 ms">
    Pack the whole environment (compilers, deps, warm caches) into a [template](/platform/instances#instance-templates): a snapshot with all that state already initialized.
    Size stops mattering.
  </ValueCard>
  <ValueCard title="Run as many as you need" metric="100K+ microVMs / server">
    Run thousands of instances with minimal memory footprints on a platform built for scale, all on the same server.
  </ValueCard>
  <ValueCard title="Inject the code to build, instantly" metric="no image rebuild">
    The code under test arrives as a [ROM](/features/roms), a small read-only image mounted at start.
    Same environment, different payload per job, no rebuild.
  </ValueCard>
</ValueCards>

<FlowDiagram caption="One base image, one template, one small ROM per job. Everything right of the template happens in milliseconds.">
  <FlowBox title="Base image">
    Your Dockerfile: toolchain, deps, caches
  </FlowBox>
  <FlowArrow label="snapshot once" />
  <FlowBox accent title="Template">
    Heavy initialisation done once, booted and frozen
  </FlowBox>
  <FlowArrow accent label="< 10 ms each" sublabel="+ ROM per job" />
  <FlowStack more="...thousands more, scaled to zero when idle">
    <FlowStackItem label="build env" chip="rom: pr-482" />
    <FlowStackItem label="build env" chip="rom: pr-483" />
    <FlowStackItem label="test env" chip="rom: nightly" />
  </FlowStack>
</FlowDiagram>

Watch the recording to see a build environment snapshotted into a template, then two different builds injected as ROMs with 6 ms cold starts from both.

<UseCaseCast
  src="build-env.cast"
  captions="build-env.captions.json"
/>

---

## Under the hood

The platform features this use case is built on.

<FeatureTable>
  <FeatureRow title="Templates" href="/platform/instances#instance-templates">
    Pre-initialised snapshots let you do the heavy initialisation once, save the state, and start new instances from it, cutting startup to milliseconds.
  </FeatureRow>
  <FeatureRow title="ROMs" href="/features/roms">
    Read-only blobs mounted on a VM.
    Combined with templates, they carry the per-job code onto each instance created from the template.
  </FeatureRow>
  <FeatureRow title="Scale-to-zero" href="/features/scale-to-zero">
    The instance shuts down when no work is running and comes back in milliseconds on the next request.
    You pay only for what you use.
  </FeatureRow>
</FeatureTable>

<UseCaseCta
  title="Run your first build environment now"
  guideHref="/guides/build-environments"
  guideLabel="Build environments guide"
>
  Sign up to Unikraft Cloud and follow the guide to run your first build environment
</UseCaseCta>

{/* vale on */}
