From e721413233f62baca4e60cc47340e8890488637f Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Apr 24 2024 19:51:36 +0000 Subject: Add Containerfile to make building locally easier This is a simplified version of the one in centos-bootc. The focus is purely on wrapping the rpm-ostree compose step. Add instructions on how to use this Containerfile. Copy in the necessary `fedora-bootc-config.json` file from centos-bootc. --- diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..5eb95eb --- /dev/null +++ b/Containerfile @@ -0,0 +1,20 @@ +# This Containerfile provides a more friendly way to build base images locally. +# To build this Containerfile, you *must* use podman/buildah. See README.md for +# details. For more information about the techniques used here, see the CentOS +# equivalent of this approach: +# +# https://github.com/CentOS/centos-bootc/blob/main/Containerfile.centos-stream9 + +# This is just a convenient image which has rpm-ostree in it. +FROM quay.io/centos-bootc/bootc-image-builder:latest as builder +COPY . /src +WORKDIR /src +RUN --mount=type=cache,target=/workdir \ + --mount=type=bind,rw=true,src=.,dst=/buildcontext,bind-propagation=shared \ + rpm-ostree compose image \ + --image-config fedora-bootc-config.json --cachedir=/workdir --format=ociarchive --initialize fedora-bootc.yaml /buildcontext/out.ociarchive + +FROM oci-archive:./out.ociarchive +# Need to reference builder here to force ordering. But since we have to run +# something anyway, we might as well cleanup after ourselves. +RUN --mount=type=bind,from=builder,src=.,target=/var/tmp --mount=type=bind,rw=true,src=.,dst=/buildcontext,bind-propagation=shared rm /buildcontext/out.ociarchive diff --git a/README.md b/README.md index 6e7bd17..7479717 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,31 @@ This repo contains the definition files for the base Fedora bootable container. Note that while the repo is currently hosted under the `fedora-iot` namespace, it is not tied to the IoT use case; these are generic base images. -The images here are built in Fedora by pungi and pushed to -quay.io/fedora/fedora-bootc. +The images here are built in Fedora by [pungi](https://pagure.io/pungi/) and +pushed to quay.io/fedora/fedora-bootc. + +## Building + +While the canonical images built in pungi directly call +[rpm-ostree](https://github.com/coreos/rpm-ostree), we also provide a +`Containerfile` to make it convenient for anyone to build these images locally +using only podman or buildah. Full privileges must be provided: + +``` +podman build --security-opt=label=disable --cap-add=all \ + --device /dev/fuse -t localhost/fedora-bootc . +``` + +## Customizing + +The easiest way to customize the image is by adding more directives to the +`Containerfile` in the last stage of the build (e.g. `COPY`ing files, or +`RUN`ning commands). + +It is also possible to modify the rpm-ostree treefiles directly, though that +approach is expected to lose relevance in the future. The treefile format is +documented [here](https://coreos.github.io/rpm-ostree/treefile/). You will most +likely be interested in the `packages` and `postprocess` keys. ## Motivation diff --git a/fedora-bootc-config.json b/fedora-bootc-config.json new file mode 100644 index 0000000..f5429f9 --- /dev/null +++ b/fedora-bootc-config.json @@ -0,0 +1,9 @@ +{ + "Labels": { + "containers.bootc": "1", + "bootc.diskimage-builder": "quay.io/centos-bootc/bootc-image-builder", + "redhat.id": "fedora", + "redhat.version-id": "40" + }, + "StopSignal": "SIGRTMIN+3" +}