// Module included in the following assemblies:
//
// * microshift/microshift-embed-into-rpm-ostree.adoc
// * microshift/microshift-update-rpms-ostree.adoc

:_mod-docs-content-type: PROCEDURE
[id="microshift-creating-ostree-iso_{context}"]
= Creating the {op-system-ostree} image with image builder

[role="_abstract"]
The {op-system-ostree} Installer image pulls the commit from the running container and creates an installable boot ISO with a Kickstart file configured to use the embedded `rpm-ostree` commit.

.Prerequisites

* Your build host meets the image builder system requirements.
* You installed and set up image builder and the `composer-cli` tool.
* You root-user access to your build host.
* You installed the `podman` tool.

.Procedure

. Start an `ostree` container image build by running the following command:
+
[source,terminal,subs="+quotes"]
----
$ BUILDID=$(sudo composer-cli compose start-ostree --ref "rhel/{op-system-version-major}/$(uname -m)/edge" __<microshift_blueprint>__ edge-container | awk '/^Compose/ {print $2}')
----
Replace `_<microshift_blueprint>_` with the name of your blueprint.
+
This command also returns the identification (ID) of the build for monitoring.

. You can check the status of the build periodically by running the following command:
+
[source,terminal]
----
$ sudo composer-cli compose status
----
+
.Example output of a running build
[source,terminal]
----
ID                                     Status     Time                     Blueprint                 Version   Type               Size
cc3377ec-4643-4483-b0e7-6b0ad0ae6332   RUNNING    Wed Jun 7 12:26:23 2023  microshift_blueprint      0.0.1     edge-container
----
+
.Example output of a completed build
[source,terminal]
----
ID                                     Status     Time                      Blueprint              Version   Type               Size
cc3377ec-4643-4483-b0e7-6b0ad0ae6332   FINISHED   Wed Jun 7 12:32:37 2023   microshift_blueprint   0.0.1     edge-container
----
+
[NOTE]
====
You can use the `watch` command to monitor your build if you are familiar with how to start and stop it.
====

. Download the container image using the ID and get the image ready for use by running the following command:
+
[source,terminal]
----
$ sudo composer-cli compose image ${BUILDID}
----

. Change the ownership of the downloaded container image to the current user by running the following command:
+
[source,terminal]
----
$ sudo chown $(whoami). ${BUILDID}-container.tar
----

. Add read permissions for the current user to the image by running the following command:
+
[source,terminal]
----
$ sudo chmod a+r ${BUILDID}-container.tar
----

. Bootstrap a server on port 8085 for the `ostree` container image to be consumed by the ISO build by completing the following steps:

.. Get the `IMAGEID` variable result by running the following command:
+
[source,terminal]
----
$ IMAGEID=$(cat < "./${BUILDID}-container.tar" | sudo podman load | grep -o -P '(?<=sha256[@:])[a-z0-9]*')
----

.. Use the `IMAGEID` variable result to run the Podman command step by running the following command:
+
[source,terminal]
----
$ sudo podman run -d --name=minimal-microshift-server -p 8085:8080 ${IMAGEID}
----
+
This command also returns the ID of the container saved in the `IMAGEID` variable for monitoring.

. Generate the installation program blueprint file by running the following command:
+
[source,text]
----
cat > microshift-installer.toml <<EOF
name = "microshift-installer"

description = ""
version = "0.0.0"
modules = []
groups = []
packages = []
EOF
----
