Skip to content

Commit 055e334

Browse files
cvclaude
andauthored
chore: add weekly Dockerfile base-image pin freshness check (#688)
* chore: add weekly Dockerfile base-image pin freshness check Adds a scheduled CI workflow (weekly Monday 09:00 UTC) that verifies the pinned node:22-slim digest in the Dockerfile matches the latest upstream. Includes a utility script that both checks and updates the pin, so engineers can remediate with a single copy-pasteable command. Companion to #686 which introduced the sha256 pin. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix: add curl resilience and argument validation to docker pin script Address CodeRabbit review feedback: - Add --retry, --connect-timeout, and --max-time to both curl calls - Reject unknown CLI arguments early to prevent accidental updates Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
1 parent da3f1de commit 055e334

2 files changed

Lines changed: 143 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Weekly check that the pinned Dockerfile base-image digest is still current.
5+
# Fails with an actionable message when a newer node:22-slim is available.
6+
7+
name: docker-pin-check
8+
9+
on:
10+
schedule:
11+
# Every Monday at 09:00 UTC
12+
- cron: "0 9 * * 1"
13+
workflow_dispatch:
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
check-pin:
20+
if: github.repository == 'NVIDIA/NemoClaw'
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 5
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Check Dockerfile base-image pin
28+
run: bash scripts/update-docker-pin.sh --check

‎scripts/update-docker-pin.sh‎

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/env bash
2+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# Updates the pinned sha256 digest for node:22-slim in the Dockerfile.
6+
# Queries Docker Hub for the current linux/amd64 manifest digest and
7+
# rewrites every FROM line that references node:22-slim.
8+
#
9+
# Usage:
10+
# scripts/update-docker-pin.sh # update Dockerfile in repo root
11+
# scripts/update-docker-pin.sh --check # exit 0 if up-to-date, 1 if stale
12+
13+
set -euo pipefail
14+
15+
case "${1:-}" in
16+
"" | --check) ;;
17+
*)
18+
echo "Usage: scripts/update-docker-pin.sh [--check]" >&2
19+
exit 2
20+
;;
21+
esac
22+
23+
IMAGE="node"
24+
TAG="22-slim"
25+
DOCKERFILE="${DOCKERFILE:-Dockerfile}"
26+
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
27+
DOCKERFILE_PATH="${REPO_ROOT}/${DOCKERFILE}"
28+
29+
# ---------------------------------------------------------------------------
30+
# Resolve the current multi-arch manifest digest for linux/amd64
31+
# ---------------------------------------------------------------------------
32+
resolve_latest_digest() {
33+
local token manifest
34+
35+
# Step 1: get an auth token for the Docker Hub library repo
36+
token=$(curl -fsSL --retry 3 --retry-delay 1 --retry-all-errors \
37+
--connect-timeout 10 --max-time 30 \
38+
"https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/${IMAGE}:pull" \
39+
| python3 -c "import sys,json; print(json.load(sys.stdin)['token'])")
40+
41+
if [[ -z "$token" ]]; then
42+
echo "ERROR: failed to obtain Docker Hub auth token" >&2
43+
exit 1
44+
fi
45+
46+
# Step 2: fetch the manifest list and pick the linux/amd64 digest
47+
manifest=$(curl -fsSL --retry 3 --retry-delay 1 --retry-all-errors \
48+
--connect-timeout 10 --max-time 30 \
49+
-H "Authorization: Bearer ${token}" \
50+
-H "Accept: application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.index.v1+json" \
51+
"https://registry-1.docker.io/v2/library/${IMAGE}/manifests/${TAG}")
52+
53+
local digest
54+
digest=$(echo "$manifest" | python3 -c "
55+
import sys, json
56+
data = json.load(sys.stdin)
57+
for m in data.get('manifests', []):
58+
p = m.get('platform', {})
59+
if p.get('os') == 'linux' and p.get('architecture') == 'amd64' and not p.get('variant'):
60+
print(m['digest'])
61+
break
62+
")
63+
64+
if [[ -z "$digest" ]]; then
65+
echo "ERROR: could not resolve digest for ${IMAGE}:${TAG}" >&2
66+
exit 1
67+
fi
68+
69+
echo "$digest"
70+
}
71+
72+
# ---------------------------------------------------------------------------
73+
# Extract the currently-pinned digest from the Dockerfile (first match)
74+
# ---------------------------------------------------------------------------
75+
current_digest() {
76+
sed -n "s|^FROM ${IMAGE}:${TAG}@\(sha256:[a-f0-9]*\).*|\1|p" "$DOCKERFILE_PATH" | head -1
77+
}
78+
79+
# ---------------------------------------------------------------------------
80+
# Main
81+
# ---------------------------------------------------------------------------
82+
latest=$(resolve_latest_digest)
83+
pinned=$(current_digest)
84+
85+
if [[ -z "$pinned" ]]; then
86+
echo "ERROR: no pinned digest found in ${DOCKERFILE} for ${IMAGE}:${TAG}" >&2
87+
echo "Expected lines like: FROM ${IMAGE}:${TAG}@sha256:..." >&2
88+
exit 1
89+
fi
90+
91+
if [[ "$pinned" == "$latest" ]]; then
92+
echo "OK: ${IMAGE}:${TAG} digest is already up-to-date (${pinned})"
93+
exit 0
94+
fi
95+
96+
if [[ "${1:-}" == "--check" ]]; then
97+
echo "STALE: pinned digest does not match the latest upstream digest."
98+
echo ""
99+
echo " pinned: ${pinned}"
100+
echo " latest: ${latest}"
101+
echo ""
102+
echo "To update, run:"
103+
echo ""
104+
echo " scripts/update-docker-pin.sh"
105+
echo ""
106+
exit 1
107+
fi
108+
109+
# Perform the replacement
110+
sed -i.bak "s|${IMAGE}:${TAG}@${pinned}|${IMAGE}:${TAG}@${latest}|g" "$DOCKERFILE_PATH"
111+
rm -f "${DOCKERFILE_PATH}.bak"
112+
113+
echo "Updated ${DOCKERFILE}: ${IMAGE}:${TAG} digest"
114+
echo " old: ${pinned}"
115+
echo " new: ${latest}"

0 commit comments

Comments
 (0)