Comment on page
Building your own runtime bundle
Applications started through the
hadean runcommand are always run in a sandboxed environment. By default, the user application is run in an environment where you have a minimal set of Ubuntu 20.04 packages. This enviornment is specified by what we call a runtime bundle, which can be found in
~/.hadean/sdk/bin/hadeanos/runtime-bundle.tar.xz. In this guide we will be looking at creating a new runtime environment, for those cases where the build environment is not compatible with the default runtime environment, or if we want to have extra packages installed by default.
You can also modify our default runtime bundles if you just need a few more packages! Just follow the "Preparing the runtime environment" section.
In this guide we will be looking at creating a CentOS 8 Stream runtime bundle. The CentOS image comes in a
qcow2format which is not supported by the Hadean Platform. Instead we need to generate a tarball that contains the root of our filesystem. We also want to modify the image to include our own packages. There are multiple ways in which this can be done, and in this guide we will be looking at one way of doing it.
In our case, CentOS8 Stream comes as a
qcow2, but for other OSes (such as Ubuntu) you can download the sysroot directly, which means you can skip the "Converting a qcow2 image" section.
First, let's make a copy of the filesystem. Later on, we can use something like
nsjailto install extra packages into the image.
For this step we will need:
# Download the image
# Mount the qcow2 as a RO filesystem
guestmount --format=qcow2 -a ./CentOS-Stream-GenericCloud-8-20200113.0.x86_64.qcow2 -i --ro ./centos-image
# Make a copy, which will take some time...
mkdir -p centos-stream-8
cp -a -R * ../centos-stream-8/
chmod -R u+w ./centos-stream-8/
# Unmount the `qcow2` image
# You can also remove this directory, but make sure the directory was unmounted properly
rm -r ./centos-image
# we don't need the `qcow2` image anymore
You can also remove the
qcow2image if you wish to do so.
For this step we will need:
Now that we have the root of the system, we need to add more things into it.
# You can keep the old resolv.conf if you prefer
echo nameserver 188.8.131.52 > etc/resolv.conf
echo nameserver 184.108.40.206 >> etc/resolv.conf
# This is Hadean specific, and necessary for now
mkdir -p \
We created some extra Hadean-specific directories, set up some nameservers, and now we are ready to install our packages.
We are going to be using
nsjailto install packages. There are other ways this can be done, for example by running the
qcow2image under QEMU, installing your dependencies, and then generating the tarball. In this guide we are going for a more scriptable approach. We ship
nsjailwith the Hadean SDK, and you can find it in
~/.hadean/sdk/bin/hadeanos/nsjail -Mo \
--chroot $(pwd) \
--tmpfsmount /tmp --tmpfsmount /user --tmpfsmount /dev/shm \
--bindmount_ro /dev/null \
--user 0 --group 0 \
--rlimit_as 4096 \
--rlimit_fsize 1024 \
--rlimit_nofile 512 \
-c 'dnf -y install gdb-gdbserver && dnf clean all'
What happens here is that we run
dnf -y install gdb-gdbserver && dnf clean allin our image. You can install other packages, or libraries if you wish to do so.
It is required that you install
gdbserver. Without it you won't be able to debug your Hadean applications!
Now that we're done, let's create the final artefact and update the default runtime bundle.
tar -cJf ../centos-stream-8-bundle.tar.xz .
rm -r ./centos-stream-8
# update the runtime bundle
cp centos-stream-8-bundle.tar.xz ~/.hadean/sdk/bin/hadeanos/runtime-bundle.tar.xz
Now you can run your application with
If you forgot to add things into the bundle, you can follow this section again, and modify the previously generated runtime bundle directly. Simply untar the bundle, and use
nsjailto modify it.