Skip to content

Commit 319a73c

Browse files
committed
build-sys: Always build a "from scratch" image
This changes things so we always run through https://docs.fedoraproject.org/en-US/bootc/building-from-scratch/ in our default builds, which helps work around containers/composefs-rs#132 But it will also help clean up our image building in general a bit. Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 8fab1b7 commit 319a73c

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

Dockerfile

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ COPY . /src
1515
FROM scratch as packaging
1616
COPY contrib/packaging /
1717

18-
FROM $base as base
19-
# Mark this as a test image (moved from --label build flag to fix layer caching)
20-
LABEL bootc.testimage="1"
21-
2218
# This image installs build deps, pulls in our source code, and installs updated
2319
# bootc binaries in /out. The intention is that the target rootfs is extracted from /out
2420
# back into a final stage (without the build deps etc) below.
25-
FROM base as buildroot
21+
FROM $base as buildroot
2622
# Flip this off to disable initramfs code
2723
ARG initramfs=1
2824
# This installs our buildroot, and we want to cache it independently of the rest.
@@ -40,6 +36,31 @@ FROM buildroot as sdboot-content
4036
# Writes to /out
4137
RUN /src/contrib/packaging/configure-systemdboot download
4238

39+
# We always do a "from scratch" build
40+
# https://docs.fedoraproject.org/en-US/bootc/building-from-scratch/
41+
# because this fixes https://github.com/containers/composefs-rs/issues/132
42+
# NOTE: Until we have https://gitlab.com/fedora/bootc/base-images/-/merge_requests/317
43+
# this stage will end up capturing whatever RPMs we find at this time.
44+
# NOTE: This is using the *stock* bootc binary, not the one we want to build from
45+
# local sources. We'll override it later.
46+
# NOTE: All your base belong to me.
47+
FROM $base as target-base
48+
RUN /usr/libexec/bootc-base-imagectl build-rootfs --manifest=standard /target-rootfs
49+
50+
FROM scratch as base
51+
COPY --from=target-base /target-rootfs/ /
52+
# Note we don't do any customization here yet
53+
# Mark this as a test image
54+
LABEL bootc.testimage="1"
55+
# Otherwise standard metadata
56+
LABEL containers.bootc 1
57+
LABEL ostree.bootable 1
58+
# https://pagure.io/fedora-kiwi-descriptions/pull-request/52
59+
ENV container=oci
60+
# Optional labels that only apply when running this image as a container. These keep the default entry point running under systemd.
61+
STOPSIGNAL SIGRTMIN+3
62+
CMD ["/sbin/init"]
63+
4364
# NOTE: Every RUN instruction past this point should use `--network=none`; we want to ensure
4465
# all external dependencies are clearly delineated.
4566

Justfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ lbi_images := "quay.io/curl/curl:latest quay.io/curl/curl-base:latest registry.a
4343
generic_buildargs := ""
4444
# Args for package building (no secrets needed, just builds RPMs)
4545
base_buildargs := generic_buildargs + " --build-arg=base=" + base + " --build-arg=variant=" + variant
46-
buildargs := base_buildargs + " --secret=id=secureboot_key,src=target/test-secureboot/db.key --secret=id=secureboot_cert,src=target/test-secureboot/db.crt"
46+
# - scratch builds need extra perms per https://docs.fedoraproject.org/en-US/bootc/building-from-scratch/
47+
# - we do secure boot signing here, so provide the keys
48+
buildargs := base_buildargs \
49+
+ " --cap-add=all --security-opt=label=type:container_runtime_t --device /dev/fuse" \
50+
+ " --secret=id=secureboot_key,src=target/test-secureboot/db.key --secret=id=secureboot_cert,src=target/test-secureboot/db.crt"
4751
# Args for build-sealed (no base arg, it sets that itself)
4852
sealed_buildargs := "--build-arg=variant=" + variant + " --secret=id=secureboot_key,src=target/test-secureboot/db.key --secret=id=secureboot_cert,src=target/test-secureboot/db.crt"
4953

0 commit comments

Comments
 (0)