KiriForge

In development

Kiri Forge

You give Forge a recipe, and it gives back something to run. One build engine for everything Kiri runs, written in Rust and built in the open.

In development, coming to Kiri. Forge is open source and its code is public today; it is not in a released Kiri yet. kiri build stays the command you type.

How it works.

You give Forge a recipe, and it gives back something to run. The recipe becomes a graph of small steps; stages that do not depend on each other run side by side.

Dockerfile to OCI image
  • Cached
  • Changed
  • Rebuilt
Dockerfile Plan sealed STAGE WEB STAGE API side by side FROM node COPY web/ RUN build FROM rust COPY src/changed RUN buildrebuilt COPY --fromfinal stage OCI image ready to run
Two stages run side by side. Only the changed COPY src/ step and the steps after it rebuild; the rest comes from the cache.
  1. 01

    Planned in a sealed process

    The recipe is read in a child process with no files, no network and fixed limits. A hostile recipe can only fail its own build.

  2. 02

    A graph of small steps

    A Dockerfile's stages and instructions become steps, each with the image config and history it produces.

  3. 03

    Stages run side by side

    Stages that do not depend on each other build at the same time.

  4. 04

    Cached by what each step reads

    A step whose inputs have not changed comes straight from the cache. One that has changed is never reused by mistake.

Change one file, rebuild only what read it.

Each step is cached by exactly what it reads: the step itself, its parent and the content of the files it takes in. Here is the same recipe after an edit to src/.

DockerfileYou edited src/
  1. Stage webruns beside api
  2. FROM node AS webCached
  3. COPY web/ .Cached
  4. RUN npm buildCached
  5. Stage apiruns beside web
  6. FROM rust AS apiCached
  7. COPY Cargo.toml .Cached
  8. COPY src/ ./srcChanged
  9. RUN cargo buildRebuilt
  10. Final stagewaits for both
  11. FROM scratchCached
  12. COPY --from=webCached
  13. COPY --from=apiRebuilt

This build

7
steps straight from the cache
1
step whose input changed
2
steps after it, run again
OCI imageready to run

What it reads.

Dockerfiles today, WebAssembly next, and Kirifiles after that. One build engine behind kiri build for everything Kiri runs.

  1. Today

    Dockerfiles

    Gives back: OCI images

    Reads directives, instructions, heredocs, .dockerignore and COPY/ADD rules, and writes each step's changes as a layer.

  2. Next

    WebAssembly

    Gives back: Wasm component / OCI artifact

    Next on the roadmap, producing WebAssembly components and OCI artifacts from the same engine.

  3. Later

    Kirifiles

    Status: Planned

    Planned after WebAssembly, completing one build engine for everything Kiri runs.

In Kiri, kiri build stays the command you type. Switching Kiri to Forge (kiri builder use forge, coming) is not in a released Kiri yet.

Three ways to use it.

Forge ships as a standalone executable with its own release lifecycle, and as a Rust library you can embed wherever builds run.

Standalone executable

kiri-forge build

Builds Dockerfiles standalone to OCI or Docker tar archives or local directories (-o type=oci|tar|local,dest=...), or against a running Kiri or Docker daemon.

kiri-forge build -t myapp:latest -o type=tar,dest=myapp.tar .

Persistent build worker

kiri-forge worker

A persistent Unix-socket and SCM_RIGHTS build worker for Kiri's engine, so Kiri and Kiri Forge release and update independently.

kiri-forge worker --socket /run/kiri/forge.sock --state /var/lib/kiri/build

Rust library

kiri_forge

The parser, isolated planner, .dockerignore context walker, COPY/ADD engine, layer splicer and ports traits. Running a step, storing layers and pulling base images plug in through three traits.

Cargo.toml

kiri-forge = { git = "https://github.com/libracoder/kiri-forge", tag = "v0.1.0" }

Builds on Linux and macOS (uses Unix file calls).

Open source

Built in the open, Apache-2.0.

Kiri Forge's code is public on GitHub under the Apache-2.0 licence. Read the source, run cargo test on Linux or macOS, or follow progress as Forge comes to Kiri.

Status
In development, coming to Kiri
Language
Rust (Linux and macOS)
Licence
Apache-2.0
Command in Kiri
kiri build