Store RHEL8 image layer cache in GHCR instead of the Actions cache

The nightly image build has failed since 2026-07-23 with "failed to
solve: not_found" while exporting the BuildKit layer cache, because the
repository's GitHub Actions cache is at the 10 GB limit and entries are
evicted as fast as they are written (0% cache hit rate on restore).

Use a registry cache (ci-rhel8:buildcache in GHCR) instead, which has no
size cap, and exclude the buildcache tag from the daily image cleanup.

Make the cache effective across nightly rebuilds: key the vcpkg stage on
its actual inputs (vcpkg.json, the vcpkg configuration and the vcpkg
tool) with a direct manifest install instead of copying the entire build
context, and exclude .git from the Docker build context since its
internals differ between checkouts of the same commit and invalidated
'COPY . /src' on every run. Nightly builds now reuse the compiled vcpkg
ports from the layer cache and only recompile the ResInsight warmup
stage.
This commit is contained in:
Magne Sjaastad committed 2026-07-27 15:38:46 +02:00
1 parent 87518f2f2f
commit 4b4bf29dfc
4 files changed
+38 -25

No files matched your search

+18 -20
View File
@@ -104,41 +104,39 @@ FROM base AS vcpkg-builder
ENV VCPKG_DEFAULT_BINARY_CACHE=/opt/vcpkg-cache
COPY . /src
# Copy only the inputs that determine the dependency set instead of the whole
# source tree. This keys the expensive vcpkg compile below on just these
# paths, so the layer stays valid in the BuildKit registry cache across
# ordinary source commits -- nightly rebuilds reuse the previously compiled
# vcpkg binaries instead of recompiling every port.
COPY ThirdParty/vcpkg /src/ThirdParty/vcpkg
COPY vcpkg.json /src/vcpkg.json
COPY vcpkg-configuration-rhel8.json /src/vcpkg-configuration.json
# Running the ResInsight CMake configure triggers a vcpkg manifest install,
# which compiles every dependency into VCPKG_DEFAULT_BINARY_CACHE. The same
# toolchain is used here and in the final image, so the vcpkg ABI hashes match
# and the cache is reused by CI builds. Later configure steps may fail inside
# the build container; that is tolerated as the dependencies are already built
# by then.
# A direct manifest install compiles every dependency into
# VCPKG_DEFAULT_BINARY_CACHE. The dependency set has no manifest features or
# overlay ports, and CC/CXX below match the ResInsight configure in the
# warmup stage and in CI, so the vcpkg ABI hashes match and the cache is
# reused there. x64-linux is the triplet the vcpkg CMake toolchain defaults
# to on Linux.
#
# After configure, verify the cache contains a plausible number of entries.
# After the install, verify the cache contains a plausible number of entries.
# vcpkg's `files` binary provider stores one .zip per package under
# <cache>/<2-hex>/<full-hash>.zip. ResInsight depends on ~30+ packages, so a
# threshold of 20 catches the failure mode where the configure dies early
# threshold of 20 catches the failure mode where the install dies early
# (e.g. after building only a handful of leaf deps) while staying robust to
# small manifest churn.
RUN git config --global --add safe.directory '*' \
&& cp /src/vcpkg-configuration-rhel8.json /src/vcpkg-configuration.json \
&& mkdir -p "${VCPKG_DEFAULT_BINARY_CACHE}" \
&& source /opt/rh/gcc-toolset-14/enable \
&& ( cd /src/ThirdParty/vcpkg && ./bootstrap-vcpkg.sh ) \
&& export CC=/opt/rh/gcc-toolset-14/root/usr/bin/gcc \
&& export CXX=/opt/rh/gcc-toolset-14/root/usr/bin/g++ \
&& { cmake -S /src -B /tmp/cfg -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DRESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS=true \
-DRESINSIGHT_ENABLE_UNITY_BUILD=true \
-DRESINSIGHT_ENABLE_HDF5=false \
-DRESINSIGHT_ENABLE_GRPC=false \
-DRESINSIGHT_GCC_STDCPP_EXP_PATH=/opt/libstdcxx-exp/lib \
-DCMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake \
|| true; } \
&& ( cd /src && ./ThirdParty/vcpkg/vcpkg install --triplet x64-linux ) \
&& vcpkg_zip_count=$(find "${VCPKG_DEFAULT_BINARY_CACHE}" -type f -name '*.zip' | wc -l) \
&& echo "vcpkg binary cache entries: ${vcpkg_zip_count}" \
&& test "${vcpkg_zip_count}" -ge 20 \
&& rm -rf /tmp/cfg /src
&& rm -rf /src
# -----------------------------------------------------------------------------
# Stage 3: warm the ResInsight buildcache by performing a full compile at