Skip to content

Commit 43c9c43

Browse files
committed
set up containers-storage in supermin cache
In the container native build flow where we are building from quay.io/fedora/fedora-bootc:xx it's better for the local developer use case if we don't need to pull the container from the registry on each iteration. Let's use containers-storage from the cache and also use `buildah build --layers=true` in all cases. This also bumps the default runvm cache size to account for the extra usage associated with the containers storage.
1 parent f6371b6 commit 43c9c43

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/cmd-build-with-buildah

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ build_with_buildah() {
141141
# For the source: check if there's only one remote, if so use it with get-url
142142
# For revision: rev-parse
143143
set -- build --security-opt=label=disable --cap-add=all --device /dev/fuse \
144+
--pull=newer --layers=true \
144145
--build-arg-file "$argsfile" -v "$(realpath "${tempdir}/src")":/run/src \
145146
--build-arg VERSION="${VERSION}" \
146147
--label org.opencontainers.image.source="${source}" \
@@ -169,9 +170,6 @@ build_with_buildah() {
169170
fi
170171

171172
if [ -n "$DIRECT" ]; then
172-
# turn on layer caching in the direct case; it wouldn't hurt in the
173-
# supermin path, but it'd be a waste of space on the rootfs
174-
set -- "$@" --layers=true
175173
# output to a tag since it's more convenient for development;
176174
# buildah doesn't support doing both at once
177175
# shellcheck disable=SC1090

src/cmdlib.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ runcompose_tree() {
613613

614614
# Run with cache disk.
615615
runvm_with_cache() {
616-
local cache_size=${RUNVM_CACHE_SIZE:-45G}
616+
local cache_size=${RUNVM_CACHE_SIZE:-50G}
617617
# "cache2" has an explicit label so we can find it in qemu easily
618618
if [ ! -f "${workdir}"/cache/cache2.qcow2 ]; then
619619
qemu-img create -f qcow2 cache2.qcow2.tmp "$cache_size"
@@ -773,7 +773,7 @@ if [ -n "\${cachedev}" ]; then
773773
mount -o remount,ro ${workdir}/cache
774774
fsfreeze -f ${workdir}/cache
775775
fsfreeze -u ${workdir}/cache
776-
umount ${workdir}/cache
776+
umount -R ${workdir}/cache
777777
fi
778778
umount ${workdir}
779779
/sbin/reboot -f

src/supermin-init-prelude.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ done
5555
cachedev=$(blkid -lt LABEL=cosa-cache -o device || true)
5656
if [ -n "${cachedev}" ]; then
5757
mount "${cachedev}" "${workdir}"/cache
58+
# Also set up container storage on the cache. We use a symlink
59+
# rather than configuring graphroot in containers/storage.conf
60+
# because when osbuild runs it will use the /etc/containers/storage.conf
61+
# from the host (if using host as buildroot) and then will run out
62+
# of space in "${workdir}"/cache/cache-containers-storage inside
63+
# the bwrap environment. Doing it with a symlink means we can
64+
# still use the cache from the host, but inside osbuild it will
65+
# just get a blank /var/lib/containers to operate on.
66+
mkdir -p "${workdir}"/cache/cache-containers-storage
67+
rm -rf /var/lib/containers
68+
ln -s "${workdir}"/cache/cache-containers-storage /var/lib/containers
69+
# Prune all containers and images more than a few days old. Our
70+
# inputs here change daily so this should be reasonable.
71+
podman system prune --all --force --filter until=72h
5872
else
5973
echo "No cosa-cache filesystem found!"
6074
fi

0 commit comments

Comments
 (0)