From 98a0a433a109f8e78dc508f79d0ce28fad0d33d3 Mon Sep 17 00:00:00 2001 From: yiekheng Date: Sun, 3 May 2026 10:41:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(scripts):=20publish.sh=20=E2=80=94=20drop?= =?UTF-8?q?=20bogus=20auth=20check,=20helpful=20buildx=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The 'authenticate first' reminder was checking docker system info's IndexServerAddress for 'gitea.04080616.xyz', but that field always reports Docker Hub regardless of which registries you've logged into. The reminder fired even right after a successful 'docker login' to Gitea — pure noise. Reduced to a comment for the maintainer. - The buildx error message now points at the actual root cause: buildx is usually installed at the per-user ~/.docker/cli-plugins path, which sudo doesn't see. Two fixes presented: docker group (no-sudo) or apt install docker-buildx-plugin (sudo). --- scripts/publish.sh | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/scripts/publish.sh b/scripts/publish.sh index 41ae26f..577ca52 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -51,23 +51,37 @@ EOF exit 1 fi -if ! "${DOCKER[@]}" system info --format '{{json .IndexServerAddress}}' 2>/dev/null | grep -q "gitea.04080616.xyz"; then - cat <&2 -Reminder: authenticate first as the same user that runs the build: - ${SUDO:+sudo }docker login gitea.04080616.xyz -EOF -fi +# (Earlier versions checked `docker system info` for the registry — but +# IndexServerAddress always points at Docker Hub regardless of which +# registries you've logged into, so the check was a guaranteed false +# positive. If push fails with 401, run: +# ${SUDO:+sudo }docker login gitea.04080616.xyz IMAGE_TAG="${1:-${DOCKER_IMAGE_TAG:-latest}}" ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" PLATFORMS="${CM_IMAGE_PLATFORMS:-linux/amd64}" if ! "${DOCKER[@]}" buildx version >/dev/null 2>&1; then - cat <<'EOF' >&2 -Docker Buildx is required for producing registry-compatible images. -Install/enable buildx and rerun, for example: - docker buildx create --use --name cm-bot-builder - docker buildx inspect --bootstrap + cat <&2 +Docker Buildx isn't reachable as the user this script runs docker as +(${SUDO:+root via sudo}${SUDO:-current user}). + +Likely cause: buildx is installed at the per-user path +~/.docker/cli-plugins/docker-buildx, which sudo doesn't see. + +Pick one fix: + + 1) Add yourself to the docker group (works for everything, no sudo): + sudo usermod -aG docker \$USER + newgrp docker + docker login gitea.04080616.xyz + NO_SUDO=1 bash scripts/publish.sh ${1:-latest} + + 2) Install the buildx plugin system-wide: + sudo apt install docker-buildx-plugin + sudo docker login gitea.04080616.xyz + bash scripts/publish.sh ${1:-latest} + EOF exit 1 fi