Skip to content

Commit df0ec00

Browse files
hjmjohnsonclaude
andcommitted
ENH: Dynamically resolve dockcross image tags from ITKPythonPackage
The pre-pull step was hardcoding v5.4.x image tags, but modules using v6.0b02 defaults pull different images (20260203-3dfb3ff for x64, 2025.08.12-1 for aarch64). The pre-pull cached the wrong image and the actual build script still hit Docker Hub without caching. Fetch dockcross-manylinux-set-vars.sh from the same ITKPythonPackage tag the build will use, then source it to get the correct IMAGE_TAG and CONTAINER_SOURCE. This ensures the pre-pull step always caches exactly the image the build script will need. Also add v6.0b02 image tags to the GHCR mirror workflow. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c0467ed commit df0ec00

File tree

2 files changed

+53
-20
lines changed

2 files changed

+53
-20
lines changed

.github/workflows/build-test-package-python.yml

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -86,32 +86,42 @@ jobs:
8686

8787
- name: 'Pre-pull dockcross image'
8888
run: |
89+
# Resolve the image tag dynamically from the ITKPythonPackage build scripts
90+
# so it matches exactly what the build step will pull.
91+
IPP_TAG=${{ inputs.itk-python-package-tag }}
92+
IPP_TAG=${IPP_TAG:=main}
93+
IPP_ORG=${{ inputs.itk-python-package-org }}
94+
IPP_ORG=${IPP_ORG:=InsightSoftwareConsortium}
95+
8996
MANYLINUX_PLATFORM=${{ matrix.manylinux-platform }}
90-
MANYLINUX_VERSION=$(echo ${MANYLINUX_PLATFORM} | cut -d '-' -f 1)
91-
TARGET_ARCH=$(echo ${MANYLINUX_PLATFORM} | cut -d '-' -f 2)
92-
if [[ ${MANYLINUX_VERSION} == _2_28 && ${TARGET_ARCH} == x64 ]]; then
93-
IMAGE_TAG="20240304-9e57d2b"
94-
elif [[ ${MANYLINUX_VERSION} == 2014 ]]; then
95-
IMAGE_TAG="20240304-9e57d2b"
96-
else
97-
echo "Unknown manylinux platform ${MANYLINUX_PLATFORM}, skipping pre-pull"
97+
export MANYLINUX_VERSION=$(echo ${MANYLINUX_PLATFORM} | cut -d '-' -f 1)
98+
export TARGET_ARCH=$(echo ${MANYLINUX_PLATFORM} | cut -d '-' -f 2)
99+
100+
VARS_URL="https://raw.githubusercontent.com/${IPP_ORG}/ITKPythonPackage/${IPP_TAG}/scripts/dockcross-manylinux-set-vars.sh"
101+
echo "Fetching image tags from ${VARS_URL}"
102+
curl -fsSL "${VARS_URL}" -o /tmp/set-vars.sh || { echo "Could not fetch set-vars.sh, skipping pre-pull"; exit 0; }
103+
source /tmp/set-vars.sh
104+
105+
if [[ -z ${CONTAINER_SOURCE} ]]; then
106+
echo "Could not determine container source, skipping pre-pull"
98107
exit 0
99108
fi
100-
IMAGE="dockcross/manylinux${MANYLINUX_VERSION}-${TARGET_ARCH}:${IMAGE_TAG}"
109+
110+
# Build the GHCR mirror name
101111
GHCR_IMAGE="ghcr.io/insightsoftwareconsortium/dockcross-manylinux${MANYLINUX_VERSION}-${TARGET_ARCH}:${IMAGE_TAG}"
102-
echo "Pre-pulling ${GHCR_IMAGE} (mirror of docker.io/${IMAGE})"
112+
echo "Pre-pulling ${GHCR_IMAGE} (mirror of ${CONTAINER_SOURCE})"
103113
for attempt in 1 2 3; do
104114
if docker pull "${GHCR_IMAGE}" 2>/dev/null; then
105-
docker tag "${GHCR_IMAGE}" "docker.io/${IMAGE}"
115+
docker tag "${GHCR_IMAGE}" "${CONTAINER_SOURCE}"
106116
echo "Successfully pulled from GHCR mirror"
107117
exit 0
108118
fi
109-
echo "GHCR pull attempt ${attempt} failed, trying Docker Hub..."
110-
if docker pull "docker.io/${IMAGE}"; then
111-
echo "Successfully pulled from Docker Hub"
119+
echo "GHCR pull attempt ${attempt} failed, trying upstream ${CONTAINER_SOURCE}..."
120+
if docker pull "${CONTAINER_SOURCE}"; then
121+
echo "Successfully pulled from upstream"
112122
exit 0
113123
fi
114-
echo "Docker Hub pull attempt ${attempt} failed, retrying in 15s..."
124+
echo "Upstream pull attempt ${attempt} failed, retrying in 15s..."
115125
sleep 15
116126
done
117127
echo "WARNING: All pull attempts failed, build script will retry"
@@ -214,18 +224,35 @@ jobs:
214224

215225
- name: 'Pre-pull manylinux aarch64 image'
216226
run: |
217-
IMAGE_TAG="2024-03-25-9206bd9"
218-
IMAGE="quay.io/pypa/manylinux_2_28_aarch64:${IMAGE_TAG}"
227+
# Resolve the image tag dynamically from the ITKPythonPackage build scripts
228+
IPP_TAG=${{ inputs.itk-python-package-tag }}
229+
IPP_TAG=${IPP_TAG:=main}
230+
IPP_ORG=${{ inputs.itk-python-package-org }}
231+
IPP_ORG=${IPP_ORG:=InsightSoftwareConsortium}
232+
233+
export MANYLINUX_VERSION="_2_28"
234+
export TARGET_ARCH="aarch64"
235+
236+
VARS_URL="https://raw.githubusercontent.com/${IPP_ORG}/ITKPythonPackage/${IPP_TAG}/scripts/dockcross-manylinux-set-vars.sh"
237+
echo "Fetching image tags from ${VARS_URL}"
238+
curl -fsSL "${VARS_URL}" -o /tmp/set-vars.sh || { echo "Could not fetch set-vars.sh, skipping pre-pull"; exit 0; }
239+
source /tmp/set-vars.sh
240+
241+
if [[ -z ${CONTAINER_SOURCE} ]]; then
242+
echo "Could not determine container source, skipping pre-pull"
243+
exit 0
244+
fi
245+
219246
GHCR_IMAGE="ghcr.io/insightsoftwareconsortium/dockcross-manylinux_2_28-aarch64:${IMAGE_TAG}"
220-
echo "Pre-pulling ${GHCR_IMAGE} (mirror of ${IMAGE})"
247+
echo "Pre-pulling ${GHCR_IMAGE} (mirror of ${CONTAINER_SOURCE})"
221248
for attempt in 1 2 3; do
222249
if docker pull "${GHCR_IMAGE}" 2>/dev/null; then
223-
docker tag "${GHCR_IMAGE}" "${IMAGE}"
250+
docker tag "${GHCR_IMAGE}" "${CONTAINER_SOURCE}"
224251
echo "Successfully pulled from GHCR mirror"
225252
exit 0
226253
fi
227254
echo "GHCR pull attempt ${attempt} failed, trying upstream..."
228-
if docker pull "${IMAGE}"; then
255+
if docker pull "${CONTAINER_SOURCE}"; then
229256
echo "Successfully pulled from upstream"
230257
exit 0
231258
fi

.github/workflows/mirror-dockcross-images.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,18 @@ jobs:
1717
strategy:
1818
matrix:
1919
include:
20+
# v5.4.x image tags
2021
- source: docker.io/dockcross/manylinux_2_28-x64:20240304-9e57d2b
2122
target: dockcross-manylinux_2_28-x64:20240304-9e57d2b
2223
- source: docker.io/dockcross/manylinux2014-x64:20240304-9e57d2b
2324
target: dockcross-manylinux2014-x64:20240304-9e57d2b
2425
- source: quay.io/pypa/manylinux_2_28_aarch64:2024-03-25-9206bd9
2526
target: dockcross-manylinux_2_28-aarch64:2024-03-25-9206bd9
27+
# v6.0b02 image tags
28+
- source: docker.io/dockcross/manylinux_2_28-x64:20260203-3dfb3ff
29+
target: dockcross-manylinux_2_28-x64:20260203-3dfb3ff
30+
- source: quay.io/pypa/manylinux_2_28_aarch64:2025.08.12-1
31+
target: dockcross-manylinux_2_28-aarch64:2025.08.12-1
2632

2733
steps:
2834
- name: Log in to GHCR

0 commit comments

Comments
 (0)