I made a Dockerfile-like system for rootfs (root filesystem) images #4740
kanpov
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
One of my pain points with Firecracker was the error-prone setup that is recommended for creating rootfs images, also known as putting together a bunch of Bash scripts. In my opinion, this is far inferior to just having a
Dockerfile
/Containerfile
that produces the image (in this case, not an OCI image, but rather a rootfs), so I wrote a CLI tool that uses a easy-to-understand and easy-to-write TOML build script to produce a rootfs in Rust: https://crates.io/crates/buildfs.In the README available on crates.io there is a complete getting started guide with a single TOML build script that can be executed to produce a minified systemd rootfs based on
debian:bookworm-slim
.buildfs
also supports overlays, i.e. injecting files and directories into the rootfs ("overlaying" them) in separate files that are referenced with the TOML script and packaged together into a directory/tarball (if no such references exist, we can use only the TOML script as shown in the getting started guide), and running not only inline, but also external scripts also packaged together with the TOML.The steps that
buildfs
uses to produce the rootfs are:dd
,mkfs
is run and the filesystem is mounted into a temporary location/sbin
and an example of the latter would be/dev
or/proc
as these are just empty mountpoints)By streamlining as much of the rootfs creation process as possible,
buildfs
allows you to configure only the things that matter and automate away the rest (as shown above): scripts to run and overlays to apply, which container image to use, which type of filesystem to create and how big it should be, which directories and files to save and which mountpoints to create. The example build script from the README is only 55 lines of TOML and it is enough to create an EXT4 Debian rootfs with systemd and DNS configured that is ready for use in Firecracker.Beta Was this translation helpful? Give feedback.
All reactions