Skip to content

Commit 6bb41bc

Browse files
authored
Update examples and use local ipxe script (#3097)
Signed-off-by: Itxaka <[email protected]>
1 parent 4740ada commit 6bb41bc

File tree

6 files changed

+136
-140
lines changed

6 files changed

+136
-140
lines changed

Earthfile

+6-1
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,12 @@ netboot:
613613
RUN isoinfo -x /rootfs.squashfs -R -i kairos.iso > ${ISO_NAME}.squashfs
614614
RUN isoinfo -x /boot/kernel -R -i kairos.iso > ${ISO_NAME}-kernel
615615
RUN isoinfo -x /boot/initrd -R -i kairos.iso > ${ISO_NAME}-initrd
616-
RUN envsubst >> ${ISO_NAME}.ipxe < /ipxe.tmpl
616+
RUN printf "#!ipxe\n" > ${ISO_NAME}.ipxe
617+
RUN printf "set dns 8.8.8.8\n" >> ${ISO_NAME}.ipxe
618+
RUN printf "ifconf\n" >> ${ISO_NAME}.ipxe
619+
RUN printf "kernel ${RELEASE_URL}/${VERSION}/${ISO_NAME}-kernel root=live:${RELEASE_URL}/${VERSION}/${ISO_NAME}.squashfs initrd=${ISO_NAME}-initrd rd.neednet=1 ip=dhcp rd.cos.disable netboot install-mode config_url=${config} console=tty1 console=ttyS0 rd.live.overlay.overlayfs\n" >> ${ISO_NAME}.ipxe
620+
RUN printf "initrd ${RELEASE_URL}/${VERSION}/${ISO_NAME}-initrd\n" >> ${ISO_NAME}.ipxe
621+
RUN printf "boot\n" >> ${ISO_NAME}.ipxe
617622

618623
SAVE ARTIFACT /build/$ISO_NAME.squashfs squashfs AS LOCAL build/$ISO_NAME.squashfs
619624
SAVE ARTIFACT /build/$ISO_NAME-kernel kernel AS LOCAL build/$ISO_NAME-kernel

examples/byoi/fedora-fips/Dockerfile

+40-38
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,17 @@
11
ARG BASE_IMAGE=fedora:36
2-
FROM $BASE_IMAGE as base
3-
4-
# Generate os-release file
5-
FROM quay.io/kairos/osbuilder-tools:latest as osbuilder
6-
RUN zypper install -y gettext && zypper clean
7-
RUN mkdir /workspace
8-
COPY --from=base /etc/os-release /workspace/os-release
9-
# You should change the following values according to your own versioning and other details
10-
RUN OS_NAME=kairos-core-fedora-fips \
11-
OS_VERSION=v9.9.9 \
12-
OS_ID="kairos" \
13-
OS_NAME=kairos-fedora-fips \
14-
BUG_REPORT_URL="https://github.com/YOUR_ORG/YOUR_PROJECT/issues" \
15-
HOME_URL="https://github.com/YOUR_ORG/YOUR_PROJECT" \
16-
OS_REPO="quay.io/YOUR_ORG/fedora-fips" \
17-
OS_LABEL="latest" \
18-
GITHUB_REPO="YOUR_ORG/YOUR_PROJECT" \
19-
VARIANT="fips" \
20-
FLAVOR="fedora" \
21-
/update-os-release.sh
22-
23-
FROM base
242

3+
FROM $BASE_IMAGE AS base
4+
ARG TARGETARCH
255
RUN echo "install_weak_deps=False" >> /etc/dnf/dnf.conf
266

277
RUN dnf install -y \
288
audit \
299
coreutils \
10+
cloud-utils-growpart \
3011
curl \
3112
device-mapper \
3213
dosfstools \
14+
dhcp-client \
3315
dracut \
3416
dracut-live \
3517
dracut-network \
@@ -64,28 +46,45 @@ RUN dnf install -y \
6446
which \
6547
&& dnf clean all
6648

67-
RUN mkdir -p /run/lock && \
68-
touch /usr/libexec/.keep && \
69-
systemctl enable [email protected] && \
70-
systemctl enable [email protected] && \
71-
systemctl enable [email protected] && \
72-
systemctl enable systemd-networkd && \
73-
systemctl enable systemd-resolved && \
74-
systemctl enable sshd
49+
RUN mkdir -p /run/lock
50+
RUN touch /usr/libexec/.keep
51+
RUN systemctl enable [email protected]
52+
RUN systemctl enable [email protected]
53+
RUN systemctl enable [email protected]
54+
RUN systemctl enable systemd-networkd
55+
RUN systemctl enable systemd-resolved
56+
RUN systemctl disable dnf-makecache.service
57+
RUN systemctl disable dnf-makecache.timer
58+
RUN systemctl enable sshd
59+
60+
61+
COPY --from=quay.io/kairos/framework:latest-fips / /
7562

76-
# Copy the os-release file to identify the OS
77-
COPY --from=osbuilder /workspace/os-release /etc/os-release
63+
# This is the version of your image
64+
ENV RELEASE=v9.9.9
65+
# This is the version of the upstream image
66+
ENV FLAVOR_RELEASE=36
67+
# This is the remote repository where you push your images to. It will be used for upgrades and such to search for latest releases
68+
ENV REGISTRY_AND_ORG="quay.io/YOUR_ORG/fedora-fips"
69+
# This is the model for which the os was built, i.e. rpi4, rpi3 or generic for x86/arm64
70+
ENV MODEL="generic"
71+
# This is the variant of the image, i.e. fips, core, standard
72+
ENV VARIANT="fips"
73+
# Flavor being used, i.e. fedora, ubuntu, alpine
74+
ENV FLAVOR="fedora"
75+
# Family being used, i.e. debian, rhel, arch, suse
76+
ENV FAMILY="rhel"
77+
# This is the architecture of the image, i.e. x86_64, arm64. Gets autofilled by docker
78+
ENV TARGETARCH=$TARGETARCH
7879

79-
COPY --from=quay.io/kairos/framework:master_fips-systemd / /
80+
# Create the kairos-release file to identify the OS
81+
RUN kairos-agent --debug versioneer os-release-variables > /etc/kairos-release
8082

8183
# Copy the custom dracut config file
8284
COPY dracut.conf /etc/dracut.conf.d/kairos-fips.conf
8385

84-
# Activate Kairos services
85-
RUN systemctl enable cos-setup-reconcile.timer && \
86-
systemctl enable cos-setup-fs.service && \
87-
systemctl enable cos-setup-boot.service && \
88-
systemctl enable cos-setup-network.service
86+
# Empty the /etc/machine-id file
87+
RUN printf "" > /etc/machine-id || true
8988

9089
## Generate initrd
9190
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
@@ -98,4 +97,7 @@ RUN kernel=$(ls /lib/modules | head -n1) && \
9897
# Symlink kernel HMAC
9998
RUN kernel=$(ls /boot/vmlinuz-* | head -n1) && ln -sf ."${kernel#/boot/}".hmac /boot/.vmlinuz.hmac
10099

100+
# Cleanup
101101
RUN rm -rf /boot/initramfs-*
102+
RUN rm /var/lib/dbus/machine-id || true
103+
RUN rm /etc/hostname || true

examples/byoi/fedora/Dockerfile

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
ARG BASE_IMAGE=fedora:36
22

33
FROM $BASE_IMAGE
4-
4+
ARG TARGETARCH
55
RUN echo "install_weak_deps=False" >> /etc/dnf/dnf.conf
66

77
RUN dnf install -y \
88
audit \
99
coreutils \
1010
curl \
11+
cloud-utils-growpart \
1112
device-mapper \
1213
dosfstools \
1314
dracut \
1415
dracut-live \
1516
dracut-network \
1617
dracut-squash \
18+
dhcp-client \
1719
e2fsprogs \
1820
efibootmgr \
1921
gawk \
@@ -46,7 +48,28 @@ RUN dnf install -y \
4648
RUN mkdir -p /run/lock
4749
RUN touch /usr/libexec/.keep
4850

49-
COPY --from=quay.io/kairos/framework:master_fedora / /
51+
COPY --from=quay.io/kairos/framework:latest / /
52+
# This is the version of your image
53+
ENV RELEASE=v9.9.9
54+
# This is the version of the upstream image
55+
ENV FLAVOR_RELEASE=focal
56+
# This is the remote repository where you push your images to. It will be used for upgrades and such to search for latest releases
57+
ENV REGISTRY_AND_ORG="quay.io/YOUR_ORG/ubuntu-fips"
58+
# This is the model for which the os was built, i.e. rpi4, rpi3 or generic for x86/arm64
59+
ENV MODEL="generic"
60+
# This is the variant of the image, i.e. fips, core, standard
61+
ENV VARIANT="fips"
62+
# Flavor being used, i.e. fedora, ubuntu, alpine
63+
ENV FLAVOR="ubuntu"
64+
# Family being used, i.e. debian, rhel, arch, suse
65+
ENV FAMILY="debian"
66+
# This is the architecture of the image, i.e. x86_64, arm64. Gets autofilled by docker
67+
ENV TARGETARCH=$TARGETARCH
68+
69+
# Create the kairos-release file to identify the OS
70+
RUN kairos-agent --debug versioneer os-release-variables > /etc/kairos-release
71+
# Empty the /etc/machine-id file
72+
RUN printf "" > /etc/machine-id || true
5073

5174
# Activate Kairos services
5275
RUN systemctl enable cos-setup-reconcile.timer && \
@@ -61,4 +84,8 @@ RUN kernel=$(ls /boot/vmlinuz-* | head -n1) && \
6184
RUN kernel=$(ls /lib/modules | head -n1) && \
6285
dracut -v -N -f "/boot/initrd-${kernel}" "${kernel}" && \
6386
ln -sf "initrd-${kernel}" /boot/initrd && depmod -a "${kernel}"
87+
88+
# Cleanup
6489
RUN rm -rf /boot/initramfs-*
90+
RUN rm /var/lib/dbus/machine-id || true
91+
RUN rm /etc/hostname || true

examples/byoi/rockylinux-fips/Dockerfile

+32-29
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,22 @@
11
ARG BASE_IMAGE=rockylinux:9
2-
FROM $BASE_IMAGE as base
32

4-
# Generate os-release file
5-
FROM quay.io/kairos/osbuilder-tools:latest as osbuilder
6-
RUN zypper install -y gettext && zypper clean
7-
RUN mkdir /workspace
8-
COPY --from=base /etc/os-release /workspace/os-release
9-
# You should change the following values according to your own versioning and other details
10-
RUN OS_NAME=kairos-core-rockylinux-fips \
11-
OS_VERSION=v9.9.9 \
12-
OS_ID="kairos" \
13-
OS_NAME=kairos-rockylinux-fips \
14-
BUG_REPORT_URL="https://github.com/YOUR_ORG/YOUR_PROJECT/issues" \
15-
HOME_URL="https://github.com/YOUR_ORG/YOUR_PROJECT" \
16-
OS_REPO="quay.io/YOUR_ORG/rockylinux-fips" \
17-
OS_LABEL="latest" \
18-
GITHUB_REPO="YOUR_ORG/YOUR_PROJECT" \
19-
VARIANT="fips" \
20-
FLAVOR="rockylinux" \
21-
/update-os-release.sh
22-
23-
FROM base
3+
FROM $BASE_IMAGE AS base
4+
ARG TARGETARCH
245
RUN echo "install_weak_deps=False" >> /etc/dnf/dnf.conf
256

267
RUN dnf install -y epel-release && dnf clean all
278
RUN dnf update -y
289
RUN dnf makecache
2910
RUN dnf install -y \
3011
audit \
12+
cloud-utils-growpart \
3113
device-mapper \
3214
dosfstools \
3315
dracut \
3416
dracut-live \
3517
dracut-network \
3618
dracut-squash \
19+
dhcp-client \
3720
e2fsprogs \
3821
efibootmgr \
3922
epel-release \
@@ -42,6 +25,7 @@ RUN dnf install -y \
4225
grub2-efi-x64 \
4326
grub2-efi-x64-modules \
4427
grub2-pc \
28+
gdisk \
4529
kernel \
4630
kernel-modules \
4731
kernel-modules-extra \
@@ -75,19 +59,34 @@ RUN systemctl enable systemd-resolved
7559
RUN systemctl disable dnf-makecache.service
7660
RUN systemctl enable sshd
7761

78-
# Copy the os-release file to identify the OS
79-
COPY --from=osbuilder /workspace/os-release /etc/os-release
62+
COPY --from=quay.io/kairos/framework:latest-fips / /
63+
64+
# This is the version of your image
65+
ENV RELEASE=v9.9.9
66+
# This is the version of the upstream image
67+
ENV FLAVOR_RELEASE=9
68+
# This is the remote repository where you push your images to. It will be used for upgrades and such to search for latest releases
69+
ENV REGISTRY_AND_ORG="quay.io/YOUR_ORG/rockylinux-fips"
70+
# This is the model for which the os was built, i.e. rpi4, rpi3 or generic for x86/arm64
71+
ENV MODEL="generic"
72+
# This is the variant of the image, i.e. fips, core, standard
73+
ENV VARIANT="fips"
74+
# Flavor being used, i.e. fedora, ubuntu, alpine
75+
ENV FLAVOR="rockylinux"
76+
# Family being used, i.e. debian, rhel, arch, suse
77+
ENV FAMILY="rhel"
78+
# This is the architecture of the image, i.e. x86_64, arm64. Gets autofilled by docker
79+
ENV TARGETARCH=$TARGETARCH
8080

81-
COPY --from=quay.io/kairos/framework:master_fips-systemd / /
81+
# Create the kairos-release file to identify the OS
82+
RUN kairos-agent --debug versioneer os-release-variables > /etc/kairos-release
8283

8384
# Copy the custom dracut config file
8485
COPY dracut.conf /etc/dracut.conf.d/kairos-fips.conf
8586

86-
# Activate Kairos services
87-
RUN systemctl enable cos-setup-reconcile.timer && \
88-
systemctl enable cos-setup-fs.service && \
89-
systemctl enable cos-setup-boot.service && \
90-
systemctl enable cos-setup-network.service
87+
# Empty the /etc/machine-id file
88+
RUN printf "" > /etc/machine-id || true
89+
9190

9291
## Generate initrd
9392
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
@@ -100,4 +99,8 @@ RUN kernel=$(ls /lib/modules | head -n1) && \
10099
# Symlink kernel HMAC
101100
RUN kernel=$(ls /boot/vmlinuz-* | head -n1) && ln -sf ."${kernel#/boot/}".hmac /boot/.vmlinuz.hmac
102101

102+
# Cleanup
103103
RUN rm -rf /boot/initramfs-*
104+
RUN rm /var/lib/dbus/machine-id || true
105+
RUN rm /etc/hostname || true
106+

examples/byoi/ubuntu-fips/Dockerfile

+29-42
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,6 @@
1-
2-
# Kairos framework packages for ubuntu fips
3-
FROM quay.io/kairos/framework:master_fips-systemd as kairos-fips
4-
5-
# Base ubuntu image (focal)
6-
FROM ubuntu:focal as base
7-
8-
# Generate os-release file
9-
FROM quay.io/kairos/osbuilder-tools:latest as osbuilder
10-
RUN zypper install -y gettext && zypper clean
11-
RUN mkdir /workspace
12-
COPY --from=base /etc/os-release /workspace/os-release
13-
# You should change the following values according to your own versioning and other details
14-
RUN OS_NAME=kairos-core-ubuntu-fips \
15-
OS_VERSION=v9.9.9 \
16-
OS_ID="kairos" \
17-
OS_NAME=kairos-ubuntu-fips \
18-
BUG_REPORT_URL="https://github.com/YOUR_ORG/YOUR_PROJECT/issues" \
19-
HOME_URL="https://github.com/YOUR_ORG/YOUR_PROJECT" \
20-
OS_REPO="quay.io/YOUR_ORG/ubuntu-fips" \
21-
OS_LABEL="latest" \
22-
GITHUB_REPO="YOUR_ORG/YOUR_PROJECT" \
23-
VARIANT="fips" \
24-
FLAVOR="ubuntu" \
25-
/update-os-release.sh
26-
271
# Build the custom ubuntu image
28-
FROM base
29-
2+
FROM ubuntu:24.04 AS base
3+
ARG TARGETARCH
304
# Don't get asked while running apt commands
315
ENV DEBIAN_FRONTEND=noninteractive
326

@@ -118,21 +92,31 @@ RUN apt-get install -y --no-install-recommends \
11892
&& rm -rf /var/lib/apt/lists/*
11993

12094
# Copy the Kairos framework files. We use master builds here for fedora. See https://quay.io/repository/kairos/framework?tab=tags for a list
121-
COPY --from=kairos-fips / /
122-
# Copy the os-release file to identify the OS
123-
COPY --from=osbuilder /workspace/os-release /etc/os-release
124-
125-
# Activate Kairos services
126-
RUN systemctl enable cos-setup-reconcile.timer && \
127-
systemctl enable cos-setup-fs.service && \
128-
systemctl enable cos-setup-boot.service && \
129-
systemctl enable cos-setup-network.service
95+
COPY --from=quay.io/kairos/framework:latest-fips / /
96+
97+
# This is the version of your image
98+
ENV RELEASE=v9.9.9
99+
# This is the version of the upstream image
100+
ENV FLAVOR_RELEASE=24.04
101+
# This is the remote repository where you push your images to. It will be used for upgrades and such to search for latest releases
102+
ENV REGISTRY_AND_ORG="quay.io/YOUR_ORG/ubuntu-fips"
103+
# This is the model for which the os was built, i.e. rpi4, rpi3 or generic for x86/arm64
104+
ENV MODEL="generic"
105+
# This is the variant of the image, i.e. fips, core, standard
106+
ENV VARIANT="fips"
107+
# Flavor being used, i.e. fedora, ubuntu, alpine
108+
ENV FLAVOR="ubuntu"
109+
# Family being used, i.e. debian, rhel, arch, suse
110+
ENV FAMILY="debian"
111+
# This is the architecture of the image, i.e. x86_64, arm64. Gets autofilled by docker
112+
ENV TARGETARCH=$TARGETARCH
113+
114+
# Create the kairos-release file to identify the OS
115+
RUN kairos-agent --debug versioneer os-release-variables > /etc/kairos-release
116+
# Empty the /etc/machine-id file
117+
RUN printf "" > /etc/machine-id || true
130118

131119
## Configuration
132-
## Took from: https://github.com/kairos-io/kairos/blob/master/images/Dockerfile.ubuntu-20-lts
133-
# workaround https://github.com/kairos-io/kairos/issues/949
134-
COPY dracut-broken-iscsi-ubuntu-20.patch /
135-
RUN cd /usr/lib/dracut/modules.d/95iscsi && patch < /dracut-broken-iscsi-ubuntu-20.patch && rm -rf /dracut-broken-iscsi-ubuntu-20.patch
136120

137121
COPY dracut.conf /etc/dracut.conf.d/kairos-fips.conf
138122
# CLEANUP
@@ -158,5 +142,8 @@ RUN chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo
158142
# Symlink kernel HMAC
159143
RUN kernel=$(ls /boot/vmlinuz-* | head -n1) && ln -sf ."${kernel#/boot/}".hmac /boot/.vmlinuz.hmac
160144

161-
# Clear cache
145+
# Cleanup
162146
RUN rm -rf /var/cache/* && journalctl --vacuum-size=1K && rm /etc/machine-id && rm /var/lib/dbus/machine-id && rm /etc/hostname
147+
RUN rm -rf /boot/initramfs-*
148+
RUN rm /var/lib/dbus/machine-id || true
149+
RUN rm /etc/hostname || true

0 commit comments

Comments
 (0)