toxcore/other/bootstrap_daemon/docker/update-sha256
Maxim Biro a030cdee5c
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.
2023-12-02 01:49:53 -05:00

24 lines
685 B
Bash
Executable File

#!/usr/bin/env bash
set -eux
docker_build() {
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.
if docker_build; then
exit 0
fi
# We're not good. Run it again, but now capture the output.
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.
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.
docker_build