publish script: find Docker CLI plugins under the private DOCKER_CONFIG
Build and Test / Build and Test (push) Successful in 3m31s

With an isolated DOCKER_CONFIG the CLI looks for buildx only in
$DOCKER_CONFIG/cli-plugins, fell back to the legacy builder, and rejected
--provenance. Symlink the user's plugin dir, honour Homebrew's, and fail
early if buildx is still missing.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
Miles WardandClaude Fable 5.1 committed 2026-09-17 19:21:22 -04:00
1 parent e772eb7c2b
commit 557eee9a06
1 file changed
+18 -1
+18 -1
View File
@@ -61,12 +61,28 @@ DOCKER_CONFIG="$(mktemp -d)"
export DOCKER_CONFIG
trap 'rm -rf "$DOCKER_CONFIG" "$WORKDIR"' EXIT
# CLI plugins (buildx, needed for --platform/--provenance) are looked up under
# $DOCKER_CONFIG/cli-plugins, so the private config would otherwise fall back
# to the legacy builder. Point it at the user's plugins and at Homebrew's.
if [[ -d "$HOME/.docker/cli-plugins" ]]; then
ln -s "$HOME/.docker/cli-plugins" "$DOCKER_CONFIG/cli-plugins"
fi
for extra in /opt/homebrew/lib/docker/cli-plugins /usr/local/lib/docker/cli-plugins; do
if [[ -d "$extra" ]]; then
printf '{"cliPluginsExtraDirs":["%s"]}' "$extra" > "$DOCKER_CONFIG/config.json"
break
fi
done
# Colima keeps its socket outside /var/run; an isolated DOCKER_CONFIG has no
# `currentContext`, so point at the daemon explicitly when one is not set.
if [[ -z "${DOCKER_HOST:-}" && -S "$HOME/.colima/default/docker.sock" ]]; then
export DOCKER_HOST="unix://$HOME/.colima/default/docker.sock"
fi
docker buildx version >/dev/null 2>&1 \
|| { echo "ERROR: docker buildx plugin not found (needed for --platform builds)." >&2; exit 2; }
echo
echo "==> Workspace : $WORKDIR"
echo "==> Gitea host : $GITEA_HOST"
@@ -105,7 +121,8 @@ docker build \
.
# Step 3: registry auth, written straight into the private config (see above).
printf '{"auths":{"%s":{"auth":"%s"}}}' "$GITEA_HOST" \
EXTRA_DIRS="$(sed -n 's/.*"cliPluginsExtraDirs":\(\[[^]]*\]\).*/\1/p' "$DOCKER_CONFIG/config.json" 2>/dev/null || true)"
printf '{"cliPluginsExtraDirs":%s,"auths":{"%s":{"auth":"%s"}}}' "${EXTRA_DIRS:-[]}" "$GITEA_HOST" \
"$(printf '%s:%s' "$GITEA_OWNER" "$GITEA_TOKEN" | base64 | tr -d '\n')" \
> "$DOCKER_CONFIG/config.json"