scripts: improve layer caching of container builds

The scripts installing dependencies are now copied and executed before
copying the full source tree. This allows to cache the dependency
installation layers as long as these scripts remain unchanged.
Previously, copying the entire repository invalidated the cache on every
source change. While our CI intentionally doesn't preserve cached layers
across independent runs, the changes in this patch help with local testing
when investigating issues.

Examples:
 - sudo -E make -C scripts/ci alpine GCC=1
 - sudo -E make -C scripts/ci alpine CLANG=1

Suggested-by: Andrei Vagin <avagin@google.com>
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
Radostin Stoyanov 2026-03-03 21:24:56 +00:00 committed by Andrei Vagin
parent 941f9b108b
commit a72bf212ec
11 changed files with 45 additions and 25 deletions

View file

@ -1,11 +1,12 @@
FROM alpine
ARG CC=gcc
COPY contrib/dependencies/apk-packages.sh /criu/contrib/dependencies/apk-packages.sh
RUN apk add --no-cache "$CC" && /criu/contrib/dependencies/apk-packages.sh
COPY . /criu
WORKDIR /criu
RUN apk add --no-cache "$CC" && /criu/contrib/dependencies/apk-packages.sh
RUN make mrproper && date && make -j $(nproc) CC="$CC" && date
# The rpc test cases are running as user #1000, let's add the user

View file

@ -5,10 +5,11 @@ ARG CC=gcc
# Initialize machine ID
RUN systemd-machine-id-setup
COPY . /criu
COPY contrib/dependencies/pacman-packages.sh /criu/contrib/dependencies/pacman-packages.sh
WORKDIR /criu
RUN pacman -Syu --noconfirm "$CC" && /criu/contrib/dependencies/pacman-packages.sh
RUN pacman -Syu --noconfirm "$CC" && contrib/dependencies/pacman-packages.sh
COPY . /criu
RUN make mrproper && date && make -j $(nproc) CC="$CC" && date

View file

@ -1,9 +1,12 @@
ARG CC=gcc
COPY . /criu
COPY contrib/dependencies/dnf-packages.sh /criu/contrib/dependencies/dnf-packages.sh
COPY scripts/ci/prepare-for-fedora-rawhide.sh /criu/scripts/ci/prepare-for-fedora-rawhide.sh
# prepare-for-fedora-rawhide.sh assumes we are in the criu directory
WORKDIR /criu
RUN dnf install -y "$CC" && /criu/scripts/ci/prepare-for-fedora-rawhide.sh
RUN dnf install -y "$CC" && scripts/ci/prepare-for-fedora-rawhide.sh
COPY . /criu
RUN make mrproper && date && make -j $(nproc) CC="$CC" && date

View file

@ -1,10 +1,11 @@
FROM docker.io/library/eclipse-temurin:11-alpine
ARG CC=gcc
COPY . /criu
COPY contrib/dependencies/apk-packages.sh /criu/contrib/dependencies/apk-packages.sh
WORKDIR /criu
RUN apk add --no-cache maven "$CC" && /criu/contrib/dependencies/apk-packages.sh
RUN apk add --no-cache maven "$CC" && contrib/dependencies/apk-packages.sh
COPY . /criu
RUN make mrproper && make -j $(nproc) CC="$CC"

View file

@ -1,10 +1,12 @@
FROM docker.io/library/eclipse-temurin:11-jammy
ARG CC=gcc
COPY . /criu
COPY contrib/dependencies/apt-packages.sh /criu/contrib/dependencies/apt-packages.sh
COPY contrib/apt-install /criu/contrib/apt-install
WORKDIR /criu
RUN /criu/contrib/apt-install maven "$CC" && contrib/dependencies/apt-packages.sh
RUN contrib/apt-install maven "$CC" && contrib/dependencies/apt-packages.sh
COPY . /criu
RUN make mrproper && make -j $(nproc) CC="$CC"

View file

@ -1,9 +1,11 @@
ARG CC=gcc
COPY . /criu
COPY contrib/dependencies/apt-cross-packages.sh /criu/contrib/dependencies/apt-cross-packages.sh
COPY contrib/apt-install /criu/contrib/apt-install
WORKDIR /criu
RUN /criu/contrib/apt-install "$CC" && /criu/contrib/dependencies/apt-packages.sh
RUN contrib/apt-install "$CC" && contrib/dependencies/apt-packages.sh
COPY . /criu
RUN uname -m && setarch linux32 uname -m && setarch --list

View file

@ -1,11 +1,13 @@
FROM docker.io/library/ibm-semeru-runtimes:open-11-jdk-jammy
ARG CC=gcc
COPY contrib/dependencies/apt-packages.sh /criu/contrib/dependencies/apt-packages.sh
COPY contrib/apt-install /criu/contrib/apt-install
WORKDIR /criu
RUN /criu/contrib/apt-install maven "$CC" && /criu/contrib/dependencies/apt-packages.sh
RUN mkdir -p /etc/criu && echo 'ghost-limit 16777216' > /etc/criu/default.conf
COPY . /criu
WORKDIR /criu
RUN contrib/apt-install maven "$CC" && contrib/dependencies/apt-packages.sh
RUN make mrproper && make -j $(nproc) CC="$CC"

View file

@ -23,9 +23,11 @@ ENV CROSS_COMPILE=${CROSS_TRIPLET}- \
ENV PATH="${PATH}:${CROSS_ROOT}/bin" \
PKG_CONFIG_PATH=/usr/lib/${CROSS_TRIPLET}/pkgconfig
COPY . /criu
COPY contrib/dependencies/apt-cross-packages.sh /criu/contrib/dependencies/apt-cross-packages.sh
COPY contrib/apt-install /criu/contrib/apt-install
WORKDIR /criu
RUN /criu/contrib/dependencies/apt-cross-packages.sh
RUN contrib/dependencies/apt-cross-packages.sh
COPY . /criu
RUN make mrproper && date && make -j $(nproc) zdtm && date

View file

@ -15,10 +15,12 @@ ENV CROSS_COMPILE=${CROSS_TRIPLET}- \
ENV PATH="${PATH}:${CROSS_ROOT}/bin" \
PKG_CONFIG_PATH=/usr/lib/${CROSS_TRIPLET}/pkgconfig
COPY . /criu
COPY contrib/dependencies/apt-cross-packages.sh /criu/contrib/dependencies/apt-cross-packages.sh
COPY contrib/apt-install /criu/contrib/apt-install
WORKDIR /criu
RUN /criu/contrib/dependencies/apt-cross-packages.sh
RUN contrib/dependencies/apt-cross-packages.sh
COPY . /criu
# amdgpu_plugin with armv7 is not supported
RUN make mrproper && date && \

View file

@ -1,11 +1,13 @@
ARG CC=gcc
COPY . /criu
WORKDIR /criu
# On Ubuntu, kernel modules such as ip_tables and xt_mark may not be loaded by default
# We need to install kmod to enable iptables to load these modules for us.
RUN contrib/apt-install "$CC" && contrib/dependencies/apt-packages.sh
COPY contrib/dependencies/apt-packages.sh /criu/contrib/dependencies/apt-packages.sh
COPY contrib/apt-install /criu/contrib/apt-install
WORKDIR /criu
RUN /criu/contrib/apt-install "$CC" && /criu/contrib/dependencies/apt-packages.sh
COPY . /criu
RUN git clean -dfx && date && \
# Check single object build

View file

@ -15,9 +15,11 @@ ENV CROSS_COMPILE=${CROSS_TRIPLET}- \
ENV PATH="${PATH}:${CROSS_ROOT}/bin" \
PKG_CONFIG_PATH=/usr/lib/${CROSS_TRIPLET}/pkgconfig
COPY . /criu
COPY contrib/dependencies/apt-cross-packages.sh /criu/contrib/dependencies/apt-cross-packages.sh
COPY contrib/apt-install /criu/contrib/apt-install
WORKDIR /criu
RUN /criu/contrib/dependencies/apt-cross-packages.sh
RUN contrib/dependencies/apt-cross-packages.sh
COPY . /criu
RUN make mrproper && date && make -j $(nproc) zdtm && date