From 4c69c9b9edaeb1877e548f48c4c2af8415d37d34 Mon Sep 17 00:00:00 2001 From: Luke Short Date: Tue, 4 Jun 2024 09:52:21 -0600 Subject: [PATCH] [WIP][unix_distributions][fedora] ostree container builds How to use them with Fedora and rpm-ostree. --- src/unix_distributions/fedora.rst | 75 ++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/src/unix_distributions/fedora.rst b/src/unix_distributions/fedora.rst index 873319f..f915f55 100644 --- a/src/unix_distributions/fedora.rst +++ b/src/unix_distributions/fedora.rst @@ -1057,7 +1057,7 @@ Examples: systemctl enable fedora-silverblue-readonly-sysroot.service rpm-ostree compose -^^^^^^^^^^^^^^^^^^ +'''''''''''''''''' Once the treefiles have been created, the rpm-ostree distribution can be built. It is recommended to use either Fedora Silverblue or Fedora Workstation as the host operating system for the build since they provide the required dependencies. The ``rpm-ostree`` command has to be ran with elevated privileges or else it will not work properly. @@ -1098,6 +1098,76 @@ Once the treefiles have been created, the rpm-ostree distribution can be built. [17][18] +Container +^^^^^^^^^ + +A Containerfile can be used to create a container image for use as the root file system. + +:: + + FROM //: + +The base container image to start with needs to have ``rpm-ostree`` installed and configured. Either use an existing image or use a Treefile to build a new base image. + +**Existing Images** + +Minimal images [45]: + +- CentOS Stream = quay.io/centos-bootc/centos-bootc:stream9 +- Fedora = quay.io/fedora/fedora-bootc:40 +- Fedora CoreOS (following the latest stable Fedora Atomic Desktop version) = quay.io/fedora/fedora-coreos:testing + +Images with desktop enviornments: + +- Fedora Atomic Desktop with GNOME = quay.io/fedora/fedora-silverblue +- Fedora Atomic Desktop with KDE Plasma = quay.io/fedora/fedora-kinoite + +In the Containerfile, set one of those images to be the ``FROM`` value. It is recommended to end each ``RUN`` command with ``&& ostree container commit``. DNF and RPM commands can be re-enabled by using ``RUN rpm-ostree cliwrap install-to-root /`` which will translate those to rpm-ostree commands. Real-world examples of how to customize these containers with rpm-ostree can be found `here `__. + +**Treefile** + +Build a container image archive. + +- First build: + + .. code-block:: sh + + $ rpm-ostree compose image --initialize --format=ociarchive .yaml .ociarchive + +- Next builds: + + .. code-block:: sh + + $ rpm-ostree compose image --initialize-mode=if-not-exists --format=ociarchive .yaml .ociarchive + +Build a container image and then push it to a container registry. [46] + +- First build: + + .. code-block:: sh + + $ rpm-ostree compose image --initialize --format=registry .yaml //: + +- Next builds: + + .. code-block:: sh + + $ rpm-ostree compose image --initialize-mode=if-not-exists --format=registry .yaml //: + +It is possible to convert an ostree repository to a container image [46] but not the other way around. [47] + +.. code-block:: sh + + $ ostree container encapsulate --repo= docker:////: + +**Kickstart** + +With a container image, it can be used with Kickstart to automatically install the operating system. + +:: + + ostreecontainer --no-signature-verification --url //: + Reset ~~~~~ @@ -1291,3 +1361,6 @@ Bibliography 42. "Fedora CoreOS (FCOS)." OKD 4. Accessed May 22, 2024. https://docs.okd.io/latest/architecture/architecture-rhcos.html 43. "Major Changes in Fedora CoreOS." Fedora Docs. May 22, 2024. Accessed May 22, 2024. https://docs.fedoraproject.org/en-US/fedora-coreos/major-changes/ 44. "General Availability of AlmaLinux 9.4 Stable!" AlmaLinux OS. May 6, 2024. Accessed June 3, 2024. https://almalinux.org/blog/2024-05-06-announcing-94-stable/ +45. "Getting Started with Fedora/CentOS bootc." Fedora Docs. June 3, 2024. Accessed June 3, 2024. https://docs.fedoraproject.org/en-US/bootc/getting-started/ +46. "ostree native containers." rpm-ostree. Accessed June 3, 2024. https://coreos.github.io/rpm-ostree/container/ +47. "containers: support converting existing base images? #11." GitHub ostreedev/ostree-rs-ext. May 21, 2024. Accessed June 3, 2024. https://github.com/ostreedev/ostree-rs-ext/issues/11