Skip to content

Commit 743795e

Browse files
committed
build-sys: Consolidate test image content into base
Move all content from the derived test image (hack/Containerfile) into the main Dockerfile base image. This includes nushell, cloud-init, and the other testing packages from packages.txt. This simplifies the build by avoiding the need to juggle multiple images during testing workflows - the base image now contains everything needed. Assisted-by: OpenCode (Claude Sonnet 4) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 319a73c commit 743795e

File tree

5 files changed

+19
-44
lines changed

5 files changed

+19
-44
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
!docs/
1616
# We use the spec file
1717
!contrib/
18+
# This is used to add content on top of our default base
19+
!hack/
1820
# The systemd units and baseimage bits end up in installs
1921
!systemd/
2022
!baseimage/

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ RUN /usr/libexec/bootc-base-imagectl build-rootfs --manifest=standard /target-ro
4949

5050
FROM scratch as base
5151
COPY --from=target-base /target-rootfs/ /
52+
COPY --from=src /src/hack/ /run/hack/
53+
RUN cd /run/hack/ && ./provision-derived.sh
5254
# Note we don't do any customization here yet
5355
# Mark this as a test image
5456
LABEL bootc.testimage="1"

hack/Containerfile

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,10 @@ FROM scratch as context
77
# We only need this stuff in the initial context
88
COPY . /
99

10-
# An intermediate layer which caches the extended RPMS
11-
FROM localhost/bootc as extended
12-
# And this layer has additional stuff for testing, such as nushell etc.
13-
RUN --mount=type=bind,from=context,target=/run/context <<EORUN
14-
set -xeuo pipefail
15-
cd /run/context/
16-
./provision-derived.sh
17-
EORUN
18-
1910
# And the configs
20-
FROM extended
11+
FROM localhost/bootc
2112
RUN --mount=type=bind,from=context,target=/run/context <<EORUN
2213
set -xeuo pipefail
2314
cd /run/context
24-
# For test-22-logically-bound-install
25-
cp -a lbi/usr/. /usr
26-
for x in curl.container curl-base.image podman.image; do
27-
ln -s /usr/share/containers/systemd/$x /usr/lib/bootc/bound-images.d/$x
28-
done
29-
30-
# Add some testing kargs into our dev builds
31-
install -D -t /usr/lib/bootc/kargs.d test-kargs/*
32-
# Also copy in some default install configs we use for testing
33-
install -D -t /usr/lib/bootc/install/ install-test-configs/*
34-
# Finally, test our own linting
3515
bootc container lint --fatal-warnings
3616
EORUN

hack/Containerfile.packit

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,7 @@ cp test-artifacts.repo /etc/yum.repos.d/
2929
dnf -y update bootc
3030
# Required by tmt avc checking after test
3131
dnf -y install audit
32-
./provision-derived.sh cloudinit
33-
34-
# For test-22-logically-bound-install
35-
cp -a lbi/usr/. /usr
36-
for x in curl.container curl-base.image podman.image; do
37-
ln -s /usr/share/containers/systemd/$x /usr/lib/bootc/bound-images.d/$x
38-
done
39-
40-
# Add some testing kargs into our dev builds
41-
install -D -t /usr/lib/bootc/kargs.d test-kargs/*
42-
# Also copy in some default install configs we use for testing
43-
install -D -t /usr/lib/bootc/install/ install-test-configs/*
32+
./provision-derived.sh
4433

4534
# Remove bootc repo, bootc updated already
4635
rm -rf /var/share/test-artifacts /etc/yum.repos.d/test-artifacts.repo

hack/provision-derived.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ set -xeu
44
# using it in our test suite because it's better than bash. First,
55
# enable EPEL to get it.
66

7-
cloudinit=0
8-
case ${1:-} in
9-
cloudinit) cloudinit=1 ;;
10-
"") ;;
11-
*) echo "Unhandled flag: ${1:-}" 1>&2; exit 1 ;;
12-
esac
13-
147
# Ensure this is pre-created
158
mkdir -p -m 0700 /var/roothome
169
mkdir -p ~/.config/nushell
@@ -51,16 +44,14 @@ grep -Ev -e '^#' packages.txt | xargs dnf -y install
5144
cat <<KARGEOF >> /usr/lib/bootc/kargs.d/20-console.toml
5245
kargs = ["console=ttyS0,115200n8"]
5346
KARGEOF
54-
if test $cloudinit = 1; then
55-
dnf -y install cloud-init
56-
ln -s ../cloud-init.target /usr/lib/systemd/system/default.target.wants
47+
dnf -y install cloud-init
48+
ln -s ../cloud-init.target /usr/lib/systemd/system/default.target.wants
5749
# Allow root SSH login for testing with bcvk/tmt
5850
mkdir -p /etc/cloud/cloud.cfg.d
5951
cat > /etc/cloud/cloud.cfg.d/80-enable-root.cfg <<'CLOUDEOF'
6052
# Enable root login for testing
6153
disable_root: false
6254
CLOUDEOF
63-
fi
6455

6556
dnf clean all
6657
# Stock extra cleaning of logs and caches in general (mostly dnf)
@@ -115,3 +106,14 @@ d /var/lib/dhclient 0755 root root - -
115106
EOF
116107
rm -rf /var/lib/dhclient
117108
fi
109+
110+
# For test-22-logically-bound-install
111+
cp -a lbi/usr/. /usr
112+
for x in curl.container curl-base.image podman.image; do
113+
ln -s /usr/share/containers/systemd/$x /usr/lib/bootc/bound-images.d/$x
114+
done
115+
116+
# Add some testing kargs into our dev builds
117+
install -D -t /usr/lib/bootc/kargs.d test-kargs/*
118+
# Also copy in some default install configs we use for testing
119+
install -D -t /usr/lib/bootc/install/ install-test-configs/*

0 commit comments

Comments
 (0)