Skip to content

chore(build): BuildKit cache mounts + ccache across 4 Dockerfiles (ADR-0923) - #431

Merged
lusoris merged 1 commit into
masterfrom
chore/buildkit-cache-mounts
May 31, 2026
Merged

lusoris merged 1 commit into
masterfrom
chore/buildkit-cache-mounts

Conversation

@lusoris

@lusoris lusoris commented May 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Audit modernization #6 — switch the four primary Dockerfiles to BuildKit syntax 1.7 and wire three classes of cache mounts that cut cold-to-warm rebuild time 3-5x.

  • Dockerfile (top-level, CUDA + FFmpeg + libvmaf)
  • docker/Dockerfile.production-gpu (5 builder variants: cpu / cuda12 / rocm6 / oneapi2026 / vulkan)
  • dev/Containerfile (full dev-mcp container)
  • Dockerfile.go-server (Go server + cgo libvmaf link)

What changed

  1. apt cache mounts on /var/cache/apt + /var/lib/apt for every apt-get install, with the matching apt-lists cleanup dropped (cache lives outside the layer FS).
  2. ccache installed as a build dep and mounted at $CCACHE_DIR around every meson / ninja / cmake compile step. FFmpeg gets --cc='ccache gcc' --cxx='ccache g++'; cmake gets -DCMAKE_{C,CXX}_COMPILER_LAUNCHER=ccache; meson auto-detects ccache.
  3. Go module + build caches on Dockerfile.go-server at /go/pkg/mod and /root/.cache/go-build.
  4. vmaf user uid/gid pin to 1000 in dev/Containerfile so --mount=...,uid=1000,gid=1000 cache mounts resolve to the build identity.

Per-Dockerfile change count

File apt mounts ccache mounts Other
Dockerfile 2 2 (libvmaf, FFmpeg) syntax header, ccache install
docker/Dockerfile.production-gpu 6 5 (one per variant) syntax header, ccache install
dev/Containerfile 8 4 (libvmaf, vpl-gpu-rt, SVT-AV1+vvenc, FFmpeg) syntax header, ccache install, uid/gid pin
Dockerfile.go-server 2 1 (libvmaf) + 1 (Go cache) syntax header, ccache install
Total 18 13 —

Why sccache (per the brief) is deferred

No Rust builder stages exist in the four primary Dockerfiles today. The audit brief mentioned sccache as a forward-looking step; the cache-mount scaffolding for Rust belongs in the Phase 4 Rust bindings PR (when there's actual Rust to cache). Adding it now would be dead code. ADR-0923 §Consequences flags the follow-up.

Test plan

  • hadolint on all four Dockerfiles — only pre-existing warnings remain.
  • docker buildx build --check -f Dockerfile.go-server . — passes ("Check complete, no warnings found").
  • docker buildx build --check -f Dockerfile . — passes.
  • docker buildx build --check -f docker/Dockerfile.production-gpu . — parses; CUDA 12.0 runtime fetch is a pre-existing failure unrelated to this PR.
  • docker buildx build --check -f dev/Containerfile . — parses; warnings are pre-existing.
  • pre-commit run --files <touched files> — all green.
  • (CI) Build each variant from scratch to confirm cache populates; rebuild to confirm 3-5x speedup.

ADR-0108 deliverables

  • D1 — Research digest: docs/research/0923-buildkit-cache-mounts-rollout-2026-05-31.md.
  • D2 — Decision matrix: docs/adr/0923-buildkit-cache-mounts.md §Alternatives considered.
  • D3 — AGENTS.md invariant note: dev/AGENTS.md §BuildKit cache mount pattern (ADR-0923).
  • D4 — Reproducer / smoke-test: docker buildx build --check -f <Dockerfile> . (see Test plan).
  • D5 — Changelog fragment: changelog.d/changed/buildkit-cache-mounts.md.
  • D6 — Rebase notes: docs/rebase-notes.md §BuildKit cache mounts on container build matrix (2026-05-31).

🤖 Generated with Claude Code

@lusoris
lusoris marked this pull request as ready for review May 31, 2026 03:33
@lusoris
lusoris enabled auto-merge (squash) May 31, 2026 03:33
@lusoris
lusoris force-pushed the chore/buildkit-cache-mounts branch from 7de0ca0 to 2f06727 Compare May 31, 2026 07:35
@lusoris
lusoris marked this pull request as draft May 31, 2026 09:01
auto-merge was automatically disabled May 31, 2026 09:01

Pull request was converted to draft

@lusoris
lusoris force-pushed the chore/buildkit-cache-mounts branch from 2f06727 to 8c00cb2 Compare May 31, 2026 12:14
@lusoris
lusoris marked this pull request as ready for review May 31, 2026 12:15
@lusoris
lusoris merged commit aba6b12 into master May 31, 2026
54 of 91 checks passed
@lusoris
lusoris deleted the chore/buildkit-cache-mounts branch May 31, 2026 12:15
lusoris added a commit that referenced this pull request Jun 12, 2026
…CI) (#868)

* fix(codeql): resolve HIGH-severity security-cpp-high alerts (23 sites)

- cpp/integer-multiplication-cast-to-long (11): pre-cast one operand to
  size_t / double / ptrdiff_t before int*int multiplications in
  cambi.c, float_vif.c (log message), iqa/convolve.c (img_offset),
  moment.c, psnr.c, and vif_tools.c (four memcpy size expressions).
  Add stddef.h to convolve.c for ptrdiff_t.

- cpp/incomplete-parity-check (3): change `% 2 == 1` to `% 2 != 0`
  in vif_tools.c (assert), svm.cpp (powi loop), pdjson.c (JSON
  object key/value alternation). The == 1 form is wrong for negative
  operands; != 0 is always correct.

- cpp/wrong-type-format-argument (2): fix float_vif.c error log that
  printed size_t fields scaled_w/scaled_h with %d; change to %zu.

- cpp/world-writable-file-creation (1): in vmaf.cpp replace bare
  fopen("wb") with open(O_WRONLY|O_CREAT|O_TRUNC, 0644)+fdopen() on
  POSIX so the created file is never world-writable independent of the
  caller's umask. Add <fcntl.h>.

- cpp/path-injection (4): in test_output.c resolve the mkstemp-created
  path through realpath() immediately after creation, breaking the taint
  chain from getenv("TMPDIR") to the vmaf_write_output call site.

- cpp/toctou-race-condition (2): skipped — both sites are in test
  cleanup (RMDIR after stat assertion). The stat result drives a test
  assertion, not a security-sensitive access decision; no atomic
  replacement of open() is applicable to rmdir. Reported as skipped.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(codeql): resolve security-python-and-ci CodeQL alerts

Fixes 18 open CodeQL alerts across the Python and CI categories:

- yaml.github-actions.security.run-shell-injection (#661): move
  github.event_name, github.base_ref, and github.event.before from
  inline ${{...}} interpolation to env: vars in the SYCL clang-tidy
  detect step of lint-and-format.yml.

- python.lang.security.use-defused-xml-parse (#216, #217): replace
  xml.etree.ElementTree with defusedxml.ElementTree in
  feature_extractor.py and quality_runner.py; add defusedxml>=0.7.1
  to python/pyproject.toml and python/requirements.txt.

- py/undefined-export (#352, #353, #354, #616): restructure
  aiutils/__init__.py to do a conditional eager import of the parquet
  helpers so the names are defined when pyarrow is present, and only
  include them in __all__ when the import succeeded.

- py/stack-trace-exposure (#178, #179, #585): log exception detail
  server-side and return a generic message to the HTTP client in
  http_transport.py _handle_score (invalid JSON, bad params, scorer
  error branches).

- python.lang.security.audit.dangerous-subprocess-use-tainted-env-args
  (#227, #372): add shlex.quote() around user-supplied path arguments
  passed into shell strings in extract_ugc_features.py and
  test_bbb_e2e_v5_bug_cluster.py.

- py/file-not-closed (#677, #678): replace bare open() calls with
  context managers in test_coverage_round3.py.

- py/redundant-comparison (#427, #431): remove redundant
  assert not (x != y) lines that duplicate the preceding assert x == y.

- py/equals-hash-mismatch (#182): convert RdPoint to frozen=True
  dataclass so __eq__ and __hash__ are generated consistently.

- py/inheritance/signature-mismatch (#197): add result_dict=None
  default to EnsembleVmafQualityRunner._populate_result_dict so the
  signature is compatible with the base class.

- py/multiple-definition (#201): drop redundant assignment to
  feature_found in feature_extractor.py wildcard discovery path.

- py/str-format/surplus-named-argument (#204): remove unused
  dataset= kwarg from the format() call in routine.py.

Skipped: python.lang.security.audit.insecure-file-permissions (#373) —
  the Unix socket at 0o660 is intentional (Go sidecar node must write
  to it and runs as the same UNIX group); tightening to 0o644 would
  break the IPC channel.

Skipped: py/path-injection (#180, #181) — _validate_path() already
  resolves the path and checks it against an allowlist before any file
  operation; the data flow is secure and the CodeQL dataflow trace is a
  false positive on this allowlisted pattern.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Lusoris <lusoris@pm.me>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@lusoris lusoris added this to the 1.0.0 — First release milestone Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant