From a030cdee5c068f7886d41054475b2d0063bb967d Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Fri, 1 Dec 2023 22:42:20 -0500 Subject: [PATCH] Fix Docker tox-bootstrapd hash update failing when using BuildKit Docker is defaulting to using BuildKit for building images since version 23.0 (2023-02-01), which is not compatible with this script. The script was fishing the hash of the intermediate build container in which the build has failed, in order to run the sha256sum in that image, however with BuildKit there are no longer any intermediate build containers, which breaks the script. The legacy builder is supposedly getting removed in a future version of Docker, which is why we embrace BuildKit instead of reverting to the legacy builder via DOCKER_BUILDKIT=0: $ DOCKER_BUILDKIT=0 docker build ... DEPRECATED: The legacy builder is deprecated and will be removed in a future release. BuildKit is currently disabled; enable it by removing the DOCKER_BUILDKIT=0 environment-variable. While DOCKER_BUILDKIT=1 is unnecessary on Docker >= 23.0, it's needed for anyone running older Docker, so it makes sense to have it in for now, while everyone transitions. --- other/bootstrap_daemon/docker/update-sha256 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/other/bootstrap_daemon/docker/update-sha256 b/other/bootstrap_daemon/docker/update-sha256 index 8bf6e0d8..6f352f38 100755 --- a/other/bootstrap_daemon/docker/update-sha256 +++ b/other/bootstrap_daemon/docker/update-sha256 @@ -3,7 +3,7 @@ set -eux docker_build() { - docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node . + DOCKER_BUILDKIT=1 docker build --progress=plain -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node . } # Run Docker build once. If it succeeds, we're good. @@ -12,12 +12,11 @@ if docker_build; then fi # We're not good. Run it again, but now capture the output. -OUTPUT=$(docker_build || true 2>&1) +OUTPUT=$(docker_build 2>&1 || true) if echo "$OUTPUT" | grep '/usr/local/bin/tox-bootstrapd: FAILED'; then # This is a checksum warning, so we need to update it. - IMAGE=$(echo "$OUTPUT" | grep '^ ---> [0-9a-f]*$' | grep -o '[0-9a-f]*$' | tail -n1) - docker run --rm "$IMAGE" sha256sum /usr/local/bin/tox-bootstrapd >other/bootstrap_daemon/docker/tox-bootstrapd.sha256 + echo "$OUTPUT" | grep -Eo '[0-9a-f]{64} /usr/local/bin/tox-bootstrapd' | tail -n1 >other/bootstrap_daemon/docker/tox-bootstrapd.sha256 fi # Run once last time to complete the build.