ci(docker): persist BuildKit ccache mounts across CI runs and bound nvcc threads

Merged
GR
11d ago
+71-5

Summary

Follow-up CI speed win for docker.yml (which currently takes 2–3 hours per main push on fat-binary builds; zero conflicts with #1060–#1064).

Changes

  • Dockerfile & Dockerfile.rocm:
    • Installs ccache in the builder stage and mounts a BuildKit cache (--mount=type=cache,id=lucebox-ccache-<variant>,target=/root/.ccache, CCACHE_MAXSIZE=2G, CCACHE_COMPRESS=1).
    • Passes -DCMAKE_C_COMPILER_LAUNCHER=ccache, -DCMAKE_CXX_COMPILER_LAUNCHER=ccache, and -DCMAKE_{CUDA,HIP}_COMPILER_LAUNCHER=ccache.
    • Adds ARG LUCE_NVCC_THREADS=2 in Dockerfile and scales Ninja jobs to max(1, nproc / LUCE_NVCC_THREADS) so ninja_jobs * nvcc_threads <= nproc, avoiding peak-memory OOMs on 4-vCPU / 16-GB hosted runners during 6-arch builds while parallelizing straggler .cu compiles.
  • .github/workflows/docker.yml:
    • Persists the BuildKit /root/.ccache mount across ephemeral hosted runners via actions/cache + reproducible-containers/buildkit-cache-dance (v3.4.0), seeded from main/release builds and restored read-only on PRs.

Expected Impact

  • Incremental main and PR Docker builds reuse cached ggml-cuda/ggml-hip .o files even when server/src changes invalidate the Docker build layer.