Skip to content

Commit d2dea74

Browse files
examples: Containerfile cleanups
Move the addition of cfsctl to after the packages are installed. This lets us reuse the cached (and slow) package install layer even if cfsctl changes. Also clean up whitespace and the grouping of commands generally to make things a bit prettier. Signed-off-by: Allison Karlitskaya <[email protected]>
1 parent 2d34dd5 commit d2dea74

File tree

9 files changed

+92
-21
lines changed

9 files changed

+92
-21
lines changed

examples/bls/Containerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
FROM fedora:41
22
COPY extra /
3-
COPY cfsctl /usr/bin
43
RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
54
set -eux
6-
dnf --setopt keepcache=1 install --allowerasing -y systemd util-linux skopeo composefs strace dosfstools kernel openssh-server
5+
6+
dnf --setopt keepcache=1 install --allowerasing -y \
7+
composefs \
8+
dosfstools \
9+
kernel \
10+
openssh-server \
11+
skopeo \
12+
strace \
13+
util-linux \
14+
systemd
15+
716
systemctl enable systemd-networkd
817
passwd -d root
918
mkdir /sysroot
1019
mkdir /composefs-meta
1120
mv /boot /composefs-meta
1221
mkdir /boot
1322
EOF
23+
COPY cfsctl /usr/bin
1424
RUN true # hack to get an extra layer

examples/bls/Containerfile.arch

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
FROM archlinux AS base
22
COPY extra /
3-
COPY cfsctl /usr/bin
43
RUN <<EOF
54
set -eux
5+
66
touch /etc/machine-id
77
echo 'root=/dev/vda2' > /etc/kernel/cmdline
8+
89
pacman -Syu --noconfirm
9-
pacman -Sy --noconfirm skopeo composefs strace dosfstools linux mkinitcpio btrfs-progs openssh
10+
pacman -Sy --noconfirm \
11+
btrfs-progs \
12+
composefs \
13+
dosfstools \
14+
linux \
15+
mkinitcpio \
16+
openssh \
17+
skopeo \
18+
strace
19+
20+
kernel-install add "$(ls /usr/lib/modules)" /usr/lib/modules/"$(ls /usr/lib/modules)"/vmlinuz
21+
1022
systemctl enable systemd-networkd systemd-resolved sshd
1123
passwd -d root
1224
mkdir /sysroot
13-
kernel-install add "$(ls /usr/lib/modules)" /usr/lib/modules/"$(ls /usr/lib/modules)"/vmlinuz
1425
mkdir /composefs-meta
1526
mv /boot /composefs-meta
1627
mkdir /boot
1728
EOF
29+
COPY cfsctl /usr/bin
1830
RUN true

examples/bls/Containerfile.rawhide

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
FROM fedora:rawhide
22
COPY extra /
3-
COPY cfsctl /usr/bin
43
RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
54
set -eux
6-
dnf --setopt keepcache=1 install --allowerasing -y systemd util-linux skopeo composefs strace dosfstools kernel openssh-server
5+
6+
dnf --setopt keepcache=1 install --allowerasing -y \
7+
composefs \
8+
dosfstools \
9+
kernel \
10+
openssh-server \
11+
skopeo \
12+
strace \
13+
systemd \
14+
util-linux
15+
716
systemctl enable systemd-networkd
817
passwd -d root
918
mkdir /sysroot
1019
mkdir /composefs-meta
1120
mv /boot /composefs-meta
1221
mkdir /boot
1322
EOF
23+
COPY cfsctl /usr/bin
1424
RUN true # hack to get an extra layer

examples/bls/Containerfile.rhel9

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
# FROM docker.io/redhat/ubi9 missing: dosfstools, kernel
22
FROM quay.io/centos/centos:9
33
COPY extra /
4-
COPY cfsctl /usr/bin
54
RUN --mount=type=cache,target=/var/cache/dnf <<EOF
65
set -eux
76
mkdir -p /etc/kernel
87
touch /etc/kernel/cmdline
8+
99
echo layout=bls | tee /etc/kernel/install.conf
10+
1011
dnf --setopt keepcache=1 install --allowerasing -y \
11-
systemd util-linux skopeo composefs strace dosfstools kernel openssh-server passwd NetworkManager
12+
NetworkManager \
13+
composefs \
14+
dosfstools \
15+
kernel \
16+
openssh-server \
17+
passwd \
18+
skopeo \
19+
strace \
20+
systemd \
21+
util-linux
22+
1223
systemctl enable tmp.mount
1324
passwd -d root
1425
mkdir /sysroot
1526
mkdir /composefs-meta
1627
mv /boot /composefs-meta
1728
mkdir /boot
1829
EOF
30+
COPY cfsctl /usr/bin
1931
RUN true # hack to get an extra layer

examples/bls/Containerfile.ubuntu

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,42 @@
11
FROM ubuntu:devel
22
COPY extra /
3-
COPY cfsctl /usr/bin
4-
53
RUN <<EOF
64
set -eux
5+
76
touch /etc/machine-id
87
touch /etc/fstab
8+
99
apt update
1010
DEBIAN_FRONTEND=noninteractive apt install -y \
11-
linux-image-generic openssh-server systemd udev dosfstools \
12-
dracut btrfs-progs strace kmod linux-base \
13-
libelf1t64 systemd udev podman skopeo btrfs-progs netctl
11+
btrfs-progs \
12+
dosfstools \
13+
dracut \
14+
kmod \
15+
libelf1t64 \
16+
linux-base \
17+
linux-image-generic \
18+
netctl \
19+
openssh-server \
20+
podman \
21+
skopeo \
22+
strace \
23+
systemd \
24+
udev
25+
apt clean
26+
1427
dracut \
1528
-a "systemd-initrd composefs bash" \
1629
-d "erofs overlay" \
1730
-I "/usr/lib/systemd/systemd-sysroot-fstab-check" \
1831
--kver $(ls /usr/lib/modules) --force
32+
kernel-install add $(cd /usr/lib/modules && echo *) /boot/vmlinuz-$(cd /usr/lib/modules && echo *)
33+
1934
systemctl enable systemd-networkd systemd-resolved
2035
passwd -d root
21-
kernel-install add $(cd /usr/lib/modules && echo *) /boot/vmlinuz-$(cd /usr/lib/modules && echo *)
22-
apt clean
2336
mkdir /sysroot
2437
mkdir /composefs-meta
2538
mv /boot /composefs-meta
2639
mkdir /boot
2740
EOF
41+
COPY cfsctl /usr/bin
2842
RUN true

examples/uki/Containerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
FROM fedora:41 AS base
1717
COPY extra /
18-
COPY cfsctl /usr/bin
1918
RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
2019
set -eux
20+
2121
# we should install kernel-modules here, but can't
2222
# because it'll pull in the entire kernel with it
2323
# it seems to work fine for now....
@@ -31,11 +31,13 @@ RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
3131
strace \
3232
systemd \
3333
util-linux
34+
3435
systemctl enable systemd-networkd
3536
semanage permissive -a systemd_gpt_generator_t # for volatile-root workaround
3637
passwd -d root
3738
mkdir /sysroot
3839
EOF
40+
COPY cfsctl /usr/bin
3941

4042
FROM base AS kernel
4143
ARG COMPOSEFS_FSVERITY

examples/uki/Containerfile.arch

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
FROM archlinux AS base
22
COPY extra /
3-
COPY cfsctl /usr/bin
43
RUN <<EOF
54
set -eux
5+
66
touch /etc/machine-id
77
mkdir -p boot/EFI/Linux
8+
89
pacman -Syu --noconfirm
9-
pacman -Sy --noconfirm skopeo composefs strace dosfstools openssh linux
10+
pacman -Sy --noconfirm \
11+
composefs \
12+
dosfstools \
13+
linux \
14+
openssh \
15+
strace \
16+
skopeo
17+
1018
systemctl enable systemd-networkd systemd-resolved sshd
1119
passwd -d root
1220
mkdir /sysroot
1321
EOF
22+
COPY cfsctl /usr/bin
1423

1524
FROM base AS kernel
1625
ARG COMPOSEFS_FSVERITY

examples/unified-secureboot/Containerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
FROM fedora:41 AS base
22
COPY extra /
3-
COPY cfsctl /usr/bin
43
RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
54
set -eux
65

@@ -18,11 +17,13 @@ RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
1817
strace \
1918
systemd \
2019
util-linux
20+
2121
systemctl enable systemd-networkd
2222
semanage permissive -a systemd_gpt_generator_t # for volatile-root workaround
2323
passwd -d root
2424
mkdir /sysroot
2525
EOF
26+
COPY cfsctl /usr/bin
2627

2728
FROM base AS kernel
2829
RUN --mount=type=bind,from=base,target=/mnt/base <<EOF

examples/unified/Containerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
FROM fedora:41 AS base
22
COPY extra /
3-
COPY cfsctl /usr/bin
43
RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
54
set -eux
65

@@ -17,11 +16,13 @@ RUN --mount=type=cache,target=/var/cache/libdnf5 <<EOF
1716
strace \
1817
systemd \
1918
util-linux
19+
2020
systemctl enable systemd-networkd
2121
semanage permissive -a systemd_gpt_generator_t # for volatile-root workaround
2222
passwd -d root
2323
mkdir /sysroot
2424
EOF
25+
COPY cfsctl /usr/bin
2526

2627
FROM base AS kernel
2728
RUN --mount=type=bind,from=base,target=/mnt/base <<EOF

0 commit comments

Comments
 (0)