# KraftKit 🚀🐒🧰

[![](https://pkg.go.dev/badge/kraftkit.sh.svg)](https://pkg.go.dev/kraftkit.sh)
![](https://img.shields.io/static/v1?label=license&message=BSD-3&color=%23385177)
[![](https://img.shields.io/discord/762976922531528725.svg?label=discord&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)][unikraft-discord]
[![Go Report Card](https://goreportcard.com/badge/kraftkit.sh)](https://goreportcard.com/report/kraftkit.sh)
![Latest release](https://img.shields.io/github/v/release/unikraft/kraftkit)

KraftKit provides a suite of tools and Go-based framework for building custom, minimal, immutable lightweight unikernel virtual machines based on [Unikraft](https://unikraft.org): a fast, secure and open-source library operating system.

![](docs/demo.gif)

With KraftKit, you can easily leverage Unikraft and manage specialized, high-performance applications at every stage of their lifecycle: from construction to production.

 * [Getting started guide][kraftkit-getting-started] 📖
 * [Key differences between containers and unikernels](https://unikraft.org/docs/concepts/) 🤔
 * [Join `#kraftkit` on Unikraft's Community Discord](https://bit.ly/UnikraftDiscord) 👾

There are many benefits in running your application as a unikernel: for more information about [the performance of unikernels 🚀](https://unikraft.org/docs/features/performance/), [the added security 🔒](https://unikraft.org/docs/features/security/) and [a positive impact on the environment 🌱](https://unikraft.org/docs/features/green/) please [check out Unikraft's documentation][unikraft-docs] and the introductory chapters on these impacts


## Features

- 🚧 Build, run and package unikernel VMs;
- 🐳 Use existing Dockerfiles and Composefiles;
- 📚 Fetch and run pre-built unikernel from the [app catalog](https://github.com/unikraft/catalog);
- 🔥 Run unikernel VMs using QEMU, Xen and [Firecracker MicroVM](https://firecracker-microvm.github.io/);
- 🤹‍♀️ Daemonless unikernel local VM instance manager;
- ⛅️ Deploy unikernel VMs to the [cloud](https://unikraft.cloud);
- 🍎 Native Linux, macOS and Windows support;
- 📦 Package and push unikernels in OCI format for easy distribution;
- 🚜 ELF binary / POSIX-compatibility support;
- 🧰 Go SDK for building unikernels programmatically; and
- 🚀 _much more!_


## Installation

You can quickly and easily install KraftKit using the interactive installer.
Run the following command to get started:

```shell
curl --proto '=https' --tlsv1.2 -sSf https://get.kraftkit.sh | sh
```

Alternatively, you can download the binaries from the [releases pages](https://github.com/unikraft/kraftkit/releases).

See [additional installation instructions](https://unikraft.org/docs/cli/install).

See also the [hacking documentation on how to build KraftKit from source](https://unikraft.org/docs/cli/hacking).


### Container build environment

KraftKit ships a container build environment which you can use instead of installing any dependencies directly on your host.
It includes the `kraft` binary as well as all the additional tools and libraries for building Unikraft unikernels.
Attach a working directory on your host as a mount path volume mapped to `/workspace`, e.g.:

```shell
docker run -it --rm -v $(pwd):/workspace --entrypoint bash kraftkit.sh/base:latest
```

The above command will drop you into a container shell.
Type `exit` or Ctrl+D to quit.


## Quickstart

### Test your installation

Running unikernels with `kraft` is designed to be simple and familiar.
To test your installation of `kraft`, you can run the following:

```
kraft run unikraft.org/helloworld:latest
```

### Build your first unikernel

Building unikernels is also designed to be simple.  Build your first unikernel
by placing a `Kraftfile` into your repo and pointing it to your existing
`Dockerfile`:

```yaml
spec: v0.6

runtime: base:latest

rootfs: ./Dockerfile

cmd: ["/path/to/my-server-app"]
```

Once done, invoke:

```
kraft run .
```

### Examples and pre-built images

You can find some common project examples below:

| | Example |
|-|:-|
| ![](https://raw.githubusercontent.com/unikraft/catalog/main/.github/icons/c.svg) | [Simple "Hello, world!" application written in C](https://github.com/unikraft/catalog/tree/main/examples/helloworld-gcc13.2) |
| ![](https://raw.githubusercontent.com/unikraft/catalog/main/.github/icons/cpp.svg) | [Simple "Hello, world!" application written in C++](https://github.com/unikraft/catalog/tree/main/examples/helloworld-g%2B%2B13.2) |
| ![](https://raw.githubusercontent.com/unikraft/catalog/main/.github/icons/rust-white.svg#gh-dark-mode-only)![](https://raw.githubusercontent.com/unikraft/catalog/main/.github/icons/rust-black.svg#gh-light-mode-only) | [Simple "Hello, world!" application written in Rust built via `cargo`](https://github.com/unikraft/catalog/tree/main/examples/helloworld-rust1.75) |
| ![](https://raw.githubusercontent.com/unikraft/catalog/main/.github/icons/js.svg) | [Simple NodeJS 18 HTTP Web Server with `http`](https://github.com/unikraft/catalog/tree/main/examples/httpserver-nodejs18) |
| ![](https://raw.githubusercontent.com/unikraft/catalog/main/.github/icons/go.svg) | [Simple Go 1.21 HTTP Web Server with `net/http`](https://github.com/unikraft/catalog/tree/main/examples/httpserver-go1.21) |
| ![](https://raw.githubusercontent.com/unikraft/catalog/main/.github/icons/python3.svg) | [Simple Flask 3.0 HTTP Web Server](https://github.com/unikraft/catalog/tree/main/examples/flask3.0-python3.12) |
| ![](https://raw.githubusercontent.com/unikraft/catalog/main/.github/icons/python3.svg) | [Simple Python 3.10 HTTP Web Server with `http.server.HTTPServer`](https://github.com/unikraft/catalog/tree/main/examples/httpserver-python3.10) |

Find [more examples and applications in our community catalog](https://github.com/unikraft/catalog)!


## Use in GitHub Actions

KraftKit can be used to automatically build your application into a unikernel in a GitHub Actions workflow, "`use`" `unikraft/kraftkit@staging`.

In the following example, a repository that has been initialized with a top-level `Kraftfile` that contains a target for qemu/x86_64 will be built every time a PR is opened, synchronized or re-opened:

```yaml
name: example

on:
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  build:
    steps:
    - uses: actions/checkout@v4

    - uses: unikraft/kraftkit@staging
      with:
        workdir: .
        kraftfile: Kraftfile
        arch: x86_64
        plat: qemu
```

For other CI's and integrations, including GitLab, check out [the getting started guide](https://unikraft.org/docs/getting-started).


## Compatibility

| Hypervisor  | Supported Version    |
|-------------|----------------------|
| Xen         | <= 4.19              |
| QEMU        | <= 9.2.1 && >= 4.2.0 |
| Firecracker | >= 1.4.1             |

|                 | QEMU | Firecracker | Xen | [containerd](/oci/README.md#supported-backends) |
|-----------------|------|-------------|-----|-------------------------------------------------|
| `linux/amd64`   | ✅   | ✅          | ✅  | ✅                                              |
| `linux/arm64`   | ✅   | ✅          | --  | ✅                                              |
| `darwin/amd64`  | ✅   | --          | --  | ✅                                              |
| `darwin/arm64`  | ✅   | --          | --  | ✅                                              |
| `freebsd/amd64` | ✅   | --          | --  | ✅                                              |
| `freebsd/arm64` | ✅   | --          | --  | ✅                                              |
| `netbsd/amd64`  | ✅   | --          | --  | --                                              |
| `netbsd/arm64`  | ✅   | --          | --  | --                                              |
| `openbsd/amd64` | ✅   | --          | --  | --                                              |
| `openbsd/arm64` | ✅   | --          | --  | --                                              |


## Support, Community & Meetings

If you have any further questions or need more information about KraftKit or Unikraft, please refer to [the official Unikraft documentation][unikraft-docs] or ask for help on the Unikraft community forum.

A KraftKit Working Group (WG) meets every other Wednesday at 13:00 PM (CET) on [Discord][unikraft-discord].
Invites and additional details are available on the [Unikraft OSS Public calendar][unikraft-calendar].


## License

KraftKit is part of the [Unikraft OSS Project][unikraft-website] and licensed under `BSD-3-Clause`.

[unikraft-website]: https://unikraft.org
[unikraft-docs]: https://unikraft.org/docs
[unikraft-discord]: https://bit.ly/UnikraftDiscord
[unikraft-calendar]: https://unikraft.org/community/events/
[kraftkit-getting-started]: https://unikraft.org/docs/getting-started/
