Skip to content

Commit 2171bac

Browse files
allisonkarlitskayacgwalters
authored andcommitted
examples: clean up UKI Containerfiles
This is a similar logic to the previous commit doing the same for bls/ but we make an additional change by installing the kernel up-front. This helps caching, of course, but it also eliminates the "missing modules" problem that required us to force the modules we needed to be present in the initramfs. This is going to be important when we start using more modules like vsock support. Signed-off-by: Allison Karlitskaya <[email protected]>
1 parent 573e98b commit 2171bac

File tree

7 files changed

+59
-50
lines changed

7 files changed

+59
-50
lines changed

examples/uki/Containerfile

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,50 @@
1414
# be baked into the UKI.
1515

1616
FROM fedora:42 AS base
17-
COPY extra /
1817
RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
1918
set -eux
2019

21-
# we should install kernel-modules here, but can't
22-
# because it'll pull in the entire kernel with it
23-
# it seems to work fine for now....
20+
mkdir -p /etc/dracut.conf.d
21+
echo export DRACUT_NO_XATTR=1 > /etc/dracut.conf.d/no-xattr.conf
22+
2423
dnf --setopt keepcache=1 install --allowerasing -y \
24+
btrfs-progs \
2525
composefs \
2626
dosfstools \
27+
kernel \
2728
openssh-server \
2829
policycoreutils-python-utils \
2930
selinux-policy-targeted \
3031
skopeo \
3132
strace \
3233
systemd \
34+
systemd-boot-unsigned \
35+
systemd-ukify \
3336
util-linux
37+
EOF
38+
39+
# --- Everything above this line should hopefully stay cached ---
40+
41+
COPY cfsctl /usr/bin
42+
COPY extra /
43+
RUN <<EOF
44+
set -eux
3445

3546
systemctl enable systemd-networkd
3647
semanage permissive -a systemd_gpt_generator_t # for volatile-root workaround
3748
passwd -d root
3849
mkdir /sysroot
3950
EOF
40-
COPY cfsctl /usr/bin
4151

4252
FROM base AS kernel
4353
ARG COMPOSEFS_FSVERITY
4454
RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
4555
set -eux
56+
4657
mkdir -p /etc/kernel /etc/dracut.conf.d
4758
echo "console=ttyS0,115200 composefs=${COMPOSEFS_FSVERITY} rw" > /etc/kernel/cmdline
4859

49-
# systemd-boot-unsigned: ditto
50-
# btrfs-progs: dracut wants to include this in the initramfs
51-
# ukify: dracut doesn't want to take our cmdline args?
52-
dnf --setopt keepcache=1 install -y kernel btrfs-progs systemd-boot-unsigned systemd-ukify
60+
kernel-install add-all
5361
EOF
5462

5563
FROM base AS bootable

examples/uki/Containerfile.arch

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
11
FROM archlinux AS base
2-
COPY extra /
3-
RUN <<EOF
2+
RUN --mount=type=cache,target=/var/cache/pacman/pkg \
3+
--mount=type=cache,target=/var/lib/pacman/sync <<EOF
44
set -eux
55

6-
touch /etc/machine-id
7-
mkdir -p boot/EFI/Linux
8-
96
pacman -Syu --noconfirm
107
pacman -Sy --noconfirm \
118
composefs \
129
dosfstools \
1310
linux \
1411
openssh \
1512
strace \
16-
skopeo
13+
skopeo \
14+
systemd-ukify
15+
EOF
16+
17+
# --- Everything above this line should hopefully stay cached ---
18+
19+
COPY cfsctl /usr/bin
20+
COPY extra /
21+
RUN <<EOF
22+
set -eux
23+
24+
touch /etc/machine-id
25+
mkdir -p boot/EFI/Linux
1726

1827
systemctl enable systemd-networkd systemd-resolved sshd
1928
passwd -d root
2029
mkdir /sysroot
2130
EOF
22-
COPY cfsctl /usr/bin
2331

2432
FROM base AS kernel
2533
ARG COMPOSEFS_FSVERITY
2634
RUN <<EOF
2735
set -eux
28-
# systemd-boot-unsigned: ditto
2936
echo "root=/dev/vda2 console=ttyS0,115200 composefs=${COMPOSEFS_FSVERITY} rw" > /etc/kernel/cmdline
30-
pacman -Sy --noconfirm systemd-ukify
3137
mkinitcpio -p linux
3238
EOF
3339

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
# we want to make sure the virtio disk drivers get included
22
hostonly=no
3-
4-
# we need to force these in via the initramfs because we don't have modules in
5-
# the base image
6-
force_drivers+=" virtio_net vfat "

examples/unified-secureboot/Containerfile

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
11
FROM fedora:42 AS base
2-
COPY extra /
32
RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
43
set -eux
54

6-
# we should install kernel-modules here, but can't
7-
# because it'll pull in the entire kernel with it
8-
# it seems to work fine for now....
95
dnf --setopt keepcache=1 install -y \
6+
btrfs-progs \
107
composefs \
118
dosfstools \
9+
kernel \
1210
mokutil \
1311
openssh-server \
1412
policycoreutils-python-utils \
13+
sbsigntools \
1514
selinux-policy-targeted \
1615
skopeo \
1716
strace \
1817
systemd \
18+
systemd-boot-unsigned \
19+
systemd-ukify \
1920
util-linux
21+
EOF
22+
23+
# --- Everything above this line should hopefully stay cached ---
24+
25+
COPY cfsctl /usr/bin
26+
COPY extra /
27+
RUN <<EOF
28+
set -eux
2029

2130
systemctl enable systemd-networkd
2231
semanage permissive -a systemd_gpt_generator_t # for volatile-root workaround
2332
passwd -d root
2433
mkdir /sysroot
2534
EOF
26-
COPY cfsctl /usr/bin
2735

2836
FROM base AS kernel
2937
RUN --mount=type=bind,from=base,target=/mnt/base <<EOF
@@ -38,10 +46,7 @@ EOF
3846
RUN --mount=type=cache,target=/var/cache/libdnf5 \
3947
--mount=type=secret,id=key \
4048
--mount=type=secret,id=cert <<EOF
41-
# systemd-boot-unsigned: ditto
42-
# btrfs-progs: dracut wants to include this in the initramfs
43-
# ukify: dracut doesn't want to take our cmdline args?
44-
dnf --setopt keepcache=1 install -y kernel btrfs-progs systemd-boot-unsigned systemd-ukify sbsigntools
49+
kernel-install add-all
4550
EOF
4651

4752
FROM base AS bootable
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
# we want to make sure the virtio disk drivers get included
22
hostonly=no
3-
4-
# we need to force these in via the initramfs because we don't have modules in
5-
# the base image
6-
force_drivers+=" virtio_net vfat "

examples/unified/Containerfile

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
11
FROM fedora:42 AS base
2-
COPY extra /
32
RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
43
set -eux
54

6-
# we should install kernel-modules here, but can't
7-
# because it'll pull in the entire kernel with it
8-
# it seems to work fine for now....
95
dnf --setopt keepcache=1 install --allowerasing -y \
6+
btrfs-progs \
107
composefs \
118
dosfstools \
9+
kernel \
1210
policycoreutils-python-utils \
1311
openssh-server \
1412
selinux-policy-targeted \
1513
skopeo \
1614
strace \
1715
systemd \
16+
systemd-boot-unsigned \
17+
systemd-ukify \
1818
util-linux
19+
EOF
20+
21+
# --- Everything above this line should hopefully stay cached ---
22+
23+
COPY cfsctl /usr/bin
24+
COPY extra /
25+
RUN <<EOF
26+
set -eux
1927

2028
systemctl enable systemd-networkd
2129
semanage permissive -a systemd_gpt_generator_t # for volatile-root workaround
2230
passwd -d root
2331
mkdir /sysroot
2432
EOF
25-
COPY cfsctl /usr/bin
2633

2734
FROM base AS kernel
2835
RUN --mount=type=bind,from=base,target=/mnt/base <<EOF
@@ -33,12 +40,7 @@ RUN --mount=type=bind,from=base,target=/mnt/base <<EOF
3340

3441
mkdir -p /etc/kernel /etc/dracut.conf.d
3542
echo "console=ttyS0,115200 composefs=${COMPOSEFS_FSVERITY} rw" > /etc/kernel/cmdline
36-
EOF
37-
RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
38-
# systemd-boot-unsigned: ditto
39-
# btrfs-progs: dracut wants to include this in the initramfs
40-
# ukify: dracut doesn't want to take our cmdline args?
41-
dnf --setopt keepcache=1 install -y kernel btrfs-progs systemd-boot-unsigned systemd-ukify
43+
kernel-install add-all
4244
EOF
4345

4446
FROM base AS bootable
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
# we want to make sure the virtio disk drivers get included
22
hostonly=no
3-
4-
# we need to force these in via the initramfs because we don't have modules in
5-
# the base image
6-
force_drivers+=" virtio_net vfat "

0 commit comments

Comments
 (0)