manibuilder: Switch to a per-image ccache

We used to have one big, shared ccache dir used by almost all images.
This doesn't scale well when we already know that parallel builds
(for different architectures, for instance) don't have a chance to
hit the same cache entries. Also, newer versions of ccache seem to
have a problem with this setup (Debian Bookworm and Fedora 37, to be
investigated).

We pass a per-image identifier `${IDENT}` into the build and place
the cache in `/ccache/${IDENT}`. However, the configuration is kept
in the default location, e.g. `~/.ccache/ccache.conf`. We can't
configure this via ENV variables easily, because some distributions
override them.

We used to have the default 5GiB ccache limit. Now with the growing
list of images, we set a 32MiB limit per image. This should keep us
within 5GiB for a while.

Change-Id: I082f95aee050efad85867b309d363f61bfea751e
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/73471
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/util/manibuilder/Dockerfile.ubuntu-debootstrap b/util/manibuilder/Dockerfile.ubuntu-debootstrap
index 6025e72..1762506 100644
--- a/util/manibuilder/Dockerfile.ubuntu-debootstrap
+++ b/util/manibuilder/Dockerfile.ubuntu-debootstrap
@@ -22,6 +22,8 @@
 	{ apt-get -qqy install libjaylink-dev libgpiod-dev || true; } && \
 	apt-get clean
 
+RUN mkdir -p -m 1777 /ccache
+
 ENV GIT_SSL_NO_VERIFY=1
 USER mani
 
@@ -31,6 +33,12 @@
 	mkdir .ccache && chown mani:mani .ccache && \
 	git clone ${ORIGIN} flashrom
 
+ARG IDENT=mani
+ARG CCACHE_MAX=32M
+RUN \
+	ccache --set-config cache_dir=/ccache/${IDENT} && \
+	ccache --set-config max_size=${CCACHE_MAX}
+
 ENV DEVSHELL /bin/bash
 COPY mani-wrapper.sh /home/mani/
 ENTRYPOINT ["/bin/sh", "/home/mani/mani-wrapper.sh"]