Skip to content

Commit ade9134

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 9916dc3 commit ade9134

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
@@ -160,6 +160,7 @@ build_with_buildah() {
160160
# For the source: check if there's only one remote, if so use it with get-url
161161
# For revision: rev-parse
162162
set -- build --security-opt=label=disable --cap-add=all --device /dev/fuse \
163+
--pull=newer --layers=true \
163164
--build-arg-file "$argsfile" -v "$(realpath "${tempdir}/src")":/run/src \
164165
--build-arg VERSION="${VERSION}" \
165166
--label org.opencontainers.image.source="${source}" \
@@ -197,9 +198,6 @@ build_with_buildah() {
197198
fi
198199

199200
if [ -n "$DIRECT" ]; then
200-
# turn on layer caching in the direct case; it wouldn't hurt in the
201-
# supermin path, but it'd be a waste of space on the rootfs
202-
set -- "$@" --layers=true
203201
# output to a tag since it's more convenient for development;
204202
# buildah doesn't support doing both at once
205203
osname=$(eval "$(grep 'NAME=' "src/config/${argsfile}")"; echo "${NAME}")

src/cmdlib.sh

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

636636
# Run with cache disk.
637637
runvm_with_cache() {
638-
local cache_size=${RUNVM_CACHE_SIZE:-45G}
638+
local cache_size=${RUNVM_CACHE_SIZE:-50G}
639639
# "cache2" has an explicit label so we can find it in qemu easily
640640
if [ ! -f "${workdir}"/cache/cache2.qcow2 ]; then
641641
qemu-img create -f qcow2 cache2.qcow2.tmp "$cache_size"
@@ -795,7 +795,7 @@ if [ -n "\${cachedev}" ]; then
795795
mount -o remount,ro ${workdir}/cache
796796
fsfreeze -f ${workdir}/cache
797797
fsfreeze -u ${workdir}/cache
798-
umount ${workdir}/cache
798+
umount -R ${workdir}/cache
799799
fi
800800
umount ${workdir}
801801
/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)