From 48e50d2367443961a62e1d8bea4a4c9d86f95b6f Mon Sep 17 00:00:00 2001 From: Vadim Zharov Date: Wed, 29 May 2024 20:06:55 +0000 Subject: [PATCH] Adding Dockerfile to build RHEL 9 base image --- rhel-core-images/Dockerfile.rhel9 | 94 +++++++++++++++++++ rhel-core-images/README.md | 13 +++ .../rhel9/system/oem/33_tmp_mount.yaml | 10 ++ 3 files changed, 117 insertions(+) create mode 100644 rhel-core-images/Dockerfile.rhel9 create mode 100644 rhel-core-images/README.md create mode 100644 rhel-core-images/overlay/rhel9/system/oem/33_tmp_mount.yaml diff --git a/rhel-core-images/Dockerfile.rhel9 b/rhel-core-images/Dockerfile.rhel9 new file mode 100644 index 0000000..a70be1b --- /dev/null +++ b/rhel-core-images/Dockerfile.rhel9 @@ -0,0 +1,94 @@ +ARG BASE_IMAGE=registry.access.redhat.com/ubi9-init:9.4-6 + +FROM $BASE_IMAGE +ARG USERNAME +ARG PASSWORD + +RUN dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -y +# Subscription manager in redhat does not run directly in containers unless you run on a redhat host, hence we remove the rhsm-host, login to the redhat subscription and add the repos +RUN rm /etc/rhsm-host && subscription-manager register --username ${USERNAME} --password ${PASSWORD} \ + && yum repolist \ + && subscription-manager attach --auto \ + && subscription-manager repos --enable rhel-9-for-x86_64-appstream-rpms \ + && yum repolist +RUN echo "install_weak_deps=False" >> /etc/dnf/dnf.conf +# Generate machine-id because https://bugzilla.redhat.com/show_bug.cgi?id=1737355#c6 +RUN uuidgen > /etc/machine-id && dnf install -y \ + squashfs-tools \ + dracut-live \ + livecd-tools \ + dracut-squash \ + dracut-network \ + systemd-resolved \ + efibootmgr \ + dhclient \ + audit \ + sudo \ + systemd \ + systemd-networkd \ + systemd-timesyncd \ + parted \ + dracut \ + e2fsprogs \ + dosfstools \ + coreutils-single \ + device-mapper \ + grub2 \ + which \ + nano \ + gawk \ + haveged \ + polkit \ + ncurses \ + tar \ + kbd \ + lvm2 \ + zstd \ + openssh-server \ + openssh-clients \ + shim-x64 \ + grub2-pc \ + grub2-efi-x64 \ + grub2-efi-x64-modules \ + open-vm-tools \ + iscsi-initiator-utils \ + iptables ethtool socat iproute-tc conntrack \ + kernel kernel-modules kernel-modules-extra \ + rsync jq && dnf clean all + +COPY --from=quay.io/kairos/framework:v2.4.3_generic / / +RUN mkdir -p /run/lock +RUN touch /usr/libexec/.keep + +# Fix systemd link for sshd +#RUN ln -s -f /usr/lib/systemd/system/sshd.service /etc/systemd/system/sshd.service +#RUN rm /etc/systemd/system/sshd.service + +# Configure the box. The ubi image masks services for containers, we unmask them +RUN systemctl list-unit-files |grep masked |cut -f 1 -d " " | xargs systemctl unmask +RUN systemctl enable getty@tty1.service +RUN systemctl enable getty@tty2.service +RUN systemctl enable getty@tty3.service +RUN systemctl enable systemd-networkd +RUN systemctl enable systemd-resolved +RUN systemctl enable sshd +RUN systemctl disable selinux-autorelabel-mark.service +#RUN systemctl enable tmp.mount + +COPY overlay/rhel9/ / + +RUN kernel=$(ls /boot/vmlinuz-* | head -n1) && \ + ln -sf "${kernel#/boot/}" /boot/vmlinuz +RUN kernel=$(ls /lib/modules | head -n1) && \ + dracut -v -N -f "/boot/initrd-${kernel}" "${kernel}" && \ + ln -sf "initrd-${kernel}" /boot/initrd && depmod -a "${kernel}" +RUN rm -rf /boot/initramfs-* + +RUN envsubst >>/etc/os-release /: --build-arg USERNAME= --build-arg PASSWORD='' -f Dockerfile.rhel8 . +``` + +To build RHEL 9 Kairos Image, execute: +``` +docker build -t /: --build-arg USERNAME= --build-arg PASSWORD='' -f Dockerfile.rhel9 . +``` \ No newline at end of file diff --git a/rhel-core-images/overlay/rhel9/system/oem/33_tmp_mount.yaml b/rhel-core-images/overlay/rhel9/system/oem/33_tmp_mount.yaml new file mode 100644 index 0000000..09a5f98 --- /dev/null +++ b/rhel-core-images/overlay/rhel9/system/oem/33_tmp_mount.yaml @@ -0,0 +1,10 @@ +name: " tmp layout setup" +stages: + initramfs.after: + - name: mount tmp + commands: + - systemctl enable tmp.mount + fs.before: + - name: start tmp + commands: + - systemctl start tmp.mount