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.alpine b/util/manibuilder/Dockerfile.alpine
index a9bc5e3..227eb91 100644
--- a/util/manibuilder/Dockerfile.alpine
+++ b/util/manibuilder/Dockerfile.alpine
@@ -18,6 +18,8 @@
RUN [ -d /usr/share/git-core/templates ] && \
chmod -R a+r /usr/share/git-core/templates
+RUN mkdir -p -m 1777 /ccache
+
ENV GIT_SSL_NO_VERIFY=1
USER mani
@@ -27,6 +29,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/sh
COPY mani-wrapper.sh /home/mani/
ENTRYPOINT ["/bin/sh", "/home/mani/mani-wrapper.sh"]
diff --git a/util/manibuilder/Dockerfile.anita b/util/manibuilder/Dockerfile.anita
index 3bfe062..b90311f 100644
--- a/util/manibuilder/Dockerfile.anita
+++ b/util/manibuilder/Dockerfile.anita
@@ -11,6 +11,8 @@
RUN git clone https://github.com/gson1703/anita.git
RUN cd anita && python setup.py install
+RUN mkdir -p -m 1777 /ccache
+
ARG DISK_SIZE=1G
ARG INSTALL_MEM=128M
ARG INST_IMG=http://ftp.de.netbsd.org/pub/NetBSD/NetBSD-7.1/amd64/
diff --git a/util/manibuilder/Dockerfile.centos b/util/manibuilder/Dockerfile.centos
index 28389bd..6ca5214 100644
--- a/util/manibuilder/Dockerfile.centos
+++ b/util/manibuilder/Dockerfile.centos
@@ -6,6 +6,8 @@
pciutils-devel libusb-devel libusbx-devel && \
yum clean -q -y all
+RUN mkdir -p -m 1777 /ccache
+
ENV GIT_SSL_NO_VERIFY=1
USER mani
diff --git a/util/manibuilder/Dockerfile.debian-debootstrap b/util/manibuilder/Dockerfile.debian-debootstrap
index 87eabc4..8eeb4ea 100644
--- a/util/manibuilder/Dockerfile.debian-debootstrap
+++ b/util/manibuilder/Dockerfile.debian-debootstrap
@@ -9,6 +9,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
@@ -18,6 +20,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"]
diff --git a/util/manibuilder/Dockerfile.djgpp b/util/manibuilder/Dockerfile.djgpp
index 5fc7338..36cabfe 100644
--- a/util/manibuilder/Dockerfile.djgpp
+++ b/util/manibuilder/Dockerfile.djgpp
@@ -6,6 +6,8 @@
useradd -p locked -m mani && \
zypper -q install -y tar make git ccache
+RUN mkdir -p -m 1777 /ccache
+
ENV GIT_SSL_NO_VERIFY=1
USER mani
@@ -27,6 +29,12 @@
cd libgetopt && \
make && cp libgetopt.a ../lib/ && cp getopt.h ../include/
+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"]
diff --git a/util/manibuilder/Dockerfile.fedora b/util/manibuilder/Dockerfile.fedora
index c66d539..82a1e21 100644
--- a/util/manibuilder/Dockerfile.fedora
+++ b/util/manibuilder/Dockerfile.fedora
@@ -7,6 +7,8 @@
{ dnf install -q -y libgpiod-devel || true; } && \
dnf clean -q -y all
+RUN mkdir -p -m 1777 /ccache
+
ENV GIT_SSL_NO_VERIFY=1
USER mani
@@ -16,6 +18,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"]
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"]
diff --git a/util/manibuilder/Makefile b/util/manibuilder/Makefile
index e6834cf..bef0ad7 100644
--- a/util/manibuilder/Makefile
+++ b/util/manibuilder/Makefile
@@ -21,14 +21,14 @@
.INTERMEDIATE: Dockerfile.$(call ident,$(1))
$(1)-build: Dockerfile.$(call ident,$(1))
- $(QUIET_SETUP)docker build . -f $$< -t mani/$(1) $$(DOCKER_BUILD_ARGS)
+ $(QUIET_SETUP)docker build . -f $$< -t mani/$(1) --build-arg IDENT=$(call ident,$(1)) $$(DOCKER_BUILD_ARGS)
endef
$(foreach tag,$(MULTIARCH_TAGS), \
$(eval $(call build_template,$(tag),multiarch)))
djgpp\:6.1.0-build: %-build: Dockerfile.djgpp mani-wrapper.sh
- $(QUIET_SETUP)docker build . -f $< -t mani/$*
+ $(QUIET_SETUP)docker build . -f $< -t mani/$* --build-arg IDENT=$(call ident,$*)
git-check-build $(addsuffix -check-build,$(ALL_TAGS)): %-check-build:
$(QUIET_SETUP)\
@@ -56,7 +56,7 @@
docker run \
$(MANI_DOCKER_ARGS) \
--env IDENT=$(call ident,$*) \
- --volume manicache:/home/mani/.ccache \
+ --volume manicache:/ccache \
--network=manibuilder \
--name mani_$(call ident,$*) mani/$* \
"git fetch $(TEST_REMOTE) $(TEST_REVISION) && \
@@ -75,7 +75,7 @@
docker run --rm -it \
$(MANI_DOCKER_ARGS) \
--env IDENT=$(call ident,$*) \
- --volume manicache:/home/mani/.ccache \
+ --volume manicache:/ccache \
--network=manibuilder \
--entrypoint /bin/sh mani_run/$* \
/home/mani/mani-wrapper.sh \
@@ -85,7 +85,7 @@
docker run --rm -it \
$(MANI_DOCKER_ARGS) \
--env IDENT=$(call ident,$*) \
- --volume manicache:/home/mani/.ccache \
+ --volume manicache:/ccache \
--network=manibuilder \
mani/$* $(patsubst %,"%",$(SHELL_ARG)); \
fi
diff --git a/util/manibuilder/anita-wrapper.sh b/util/manibuilder/anita-wrapper.sh
index 3da4455..c404297 100644
--- a/util/manibuilder/anita-wrapper.sh
+++ b/util/manibuilder/anita-wrapper.sh
@@ -4,7 +4,7 @@
[ "${IDENT}" ] || IDENT=$(mktemp -u XXXXXXXX)
-CCACHE=.ccache/anita-${IDENT}.img
+CCACHE=/ccache/${IDENT}.img
[ -f ${CCACHE} ] || zcat cache.img.gz >${CCACHE}