codeant-ai-for-open-source[bot] commented on code in PR #44250:
URL: https://github.com/apache/superset/pull/44250#discussion_r4017689705


##########
scripts/docker-build-extra-flags.sh:
##########
@@ -31,18 +31,41 @@
 # appending PY_VER here would override supersetbot's pin and silently make
 # "py311"/"py312" build the exact same image as "lean". Every other preset
 # gets the override so its build lands on the Dockerfile's own supported
-# Python version.
+# Python version. Those presets also point buildx at a matching cache tag so
+# local and CI builds can pull cache layers for the same base image they build.
 #
-# Usage: docker-build-extra-flags.sh <build_preset> <image_tag>
+# Usage: docker-build-extra-flags.sh <build_preset> [image_tag]
 
 set -euo pipefail
 
-BUILD_PRESET="${1:?usage: docker-build-extra-flags.sh <build_preset> 
<image_tag>}"
-IMAGE_TAG="${2:?usage: docker-build-extra-flags.sh <build_preset> <image_tag>}"
+BUILD_PRESET="${1:?usage: docker-build-extra-flags.sh <build_preset> 
[image_tag]}"
+IMAGE_TAG="${2:-}"
+DEFAULT_PY_VER="$(sed -n 's/^ARG PY_VER=//p' Dockerfile | head -n 1)"
+if [ -z "$DEFAULT_PY_VER" ]; then
+  echo "Could not determine the default PY_VER from Dockerfile" >&2
+  exit 1
+fi
+
+EXTRA_FLAGS="--build-arg INCLUDE_CHROMIUM=false"
+if [ -n "$IMAGE_TAG" ]; then
+  EXTRA_FLAGS="$EXTRA_FLAGS --tag $IMAGE_TAG"
+fi
+case "$BUILD_PRESET" in
+  py311)
+    CACHE_REF="apache/superset-cache:3.11-slim-bookworm"
+    ;;
+  py312)
+    CACHE_REF="apache/superset-cache:3.12-slim-bookworm"
+    ;;
+  *)
+    CACHE_REF="apache/superset-cache:${DEFAULT_PY_VER}"
+    EXTRA_FLAGS="--build-arg PY_VER=$DEFAULT_PY_VER $EXTRA_FLAGS"
+    ;;
+esac
 
-EXTRA_FLAGS="--build-arg INCLUDE_CHROMIUM=false --tag $IMAGE_TAG"
-if [ "$BUILD_PRESET" != "py311" ] && [ "$BUILD_PRESET" != "py312" ]; then
-  EXTRA_FLAGS="--build-arg PY_VER=3.11.14-slim-trixie $EXTRA_FLAGS"
+EXTRA_FLAGS="--cache-from=type=registry,ref=$CACHE_REF $EXTRA_FLAGS"
+if [ "${PUBLISH_DOCKER_CACHE:-}" = "true" ] && [ -n "${DOCKERHUB_TOKEN:-}" ]; 
then
+  EXTRA_FLAGS="--cache-to=type=registry,mode=max,ref=$CACHE_REF $EXTRA_FLAGS"
 fi

Review Comment:
   **Suggestion:** Concurrent matrix jobs export different targets to the same 
cache tag, so later exports replace earlier cache records and cause 
nondeterministic cache misses. [cache]
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Often`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=9861d77df92444668cacd10ef53daedb&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=9861d77df92444668cacd10ef53daedb&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** scripts/docker-build-extra-flags.sh
   **Line:** 67:69
   **Comment:**
        *Cache: Concurrent matrix jobs export different targets to the same 
cache tag, so later exports replace earlier cache records and cause 
nondeterministic cache misses.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44250&comment_hash=37fc14aff0680f1477d5df93adbc8da5f72aba4bafa1aa42d0b1be86b7385ea6&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44250&comment_hash=37fc14aff0680f1477d5df93adbc8da5f72aba4bafa1aa42d0b1be86b7385ea6&reaction=dislike'>๐Ÿ‘Ž</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to