Images#
Using OCI Containers and Bootc#
This section will rely on Eclipse SDV AutoSD’s integration project: https://github.com/eclipse-autosd/eclipse-autosd.
Eclipse S-CORE module owners and developers do not need to build an image from scratch to test their applications, nor do they need to download exotic tooling to do so as well.
The building framework and workflow will rely on using OCI container images, built from Bazel, and Bootc (Bootcable Containers). The later , which is used in AutoSD, allows users to manage OS / Host modification from an OCI container image (as long as it is built from an base bootc AutoSD image).
The basic workflow/setup is:
Build your target(s) - binaries, libraries, scripts, etc
Create a syroot tarball with the previous artifacts
Pull a base AutoSD bootc image for a given platform (QEMU, RPI4, etc)
Build a new OCI image adding the generated tarball as an OCI layer on top of the base AutoSD one
Download an existing disk image (.qcow2, .img)
Apply the new deployment using the bootc CLI and the new OCI image
Reboot and test changes
Step 1: Bootc Image Definition#
The first step is to setup Bazel (MODULE.bazel) to fetch a prexisting Bootc container image:
module(name = "esdv_autosd_sample", version = "0.0.1")
bazel_dep(name = "rules_pkg", version = "1.0.1")
bazel_dep(name = "rules_oci", version = "2.3.1")
git_override(
module_name = "rules_oci",
remote = "https://github.com/bazel-contrib/rules_oci.git",
tag = "v2.3.1",
)
oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
oci.pull(
name = "eclipse_autosd_qemu",
image = "ghcr.io/eclipse-autosd/eclipse-autosd-bootc-qemu",
tag = "latest",
platforms = ["linux/amd64"],
)
use_repo(
oci,
"eclipse_autosd_qemu",
)
Step 2: Tarball + Bootc Image#
The next step is to build Bazel targets and archive the generated artifacts/files into a tarball. This tarball can be used to created a new OCI image, using the previous step’s image as the parent one:
load("@rules_pkg//pkg:pkg.bzl", "pkg_tar")
load("@rules_oci//oci:defs.bzl", "oci_load", "oci_image")
filegroup(
name = "sample_systemd_service",
srcs = ["files/sample.service"],
)
pkg_tar(
name = "sample_systemd_service_tar",
srcs = [
":sample_systemd_service",
],
symlinks = {
"/etc/systemd/system/default.target.wants/sample.service": "/etc/systemd/system/sample.service",
},
package_dir = "/etc/systemd/system",
)
pkg_tar(
name = "sample_tar",
srcs = [
"//src:sample",
],
package_dir = "/usr/bin",
)
oci_image(
name = "sample_image",
base = "@eclipse_autosd_qemu",
tars = [
":sample_tar",
":sample_systemd_service_tar",
],
)
You can then generated an oci archive (.oci file) or push it to a OCI regisry, such as Docker Hub or Quay.io.
Step 3: Deploying Changes with Bootc Switch#
The last step is to import and apply changes from the new container image into an exiting AutoSD one.
You can either build your own AutoSD image or using an existing one from here: https://download.eclipse.org/autosd/disk-images/.
The rest of this section will assume the usage the QEMU image.
Once downloaded, you can run the AutoSD QEMU image, then you will need to apply the changes from the new bootc image over ssh.
If you pushed your image to a container register run the following command over ssh:
$ bootc switch $my_image_url
$ systemctl reboot
If you generated a, oci archive, you need to upload that file with scp and run:
$ bootc switch --transport oci-archive $path_to_file
$ system reboot
- Bootc will apply all the missing/new layers into the host machine from the specified OCI Bootc image
which includes all the artifacts generated by Bazel. A reboot is needed in order for the new file system changes to take place.