Thanks to Alexander Pravdin for the original idea in this comment. Since we moved all our build-processes to depot, we don't need this anymore and have much faster and more reliable multi-arch builds.
Please see https://github.com/reproducible-containers/buildkit-cache-dance for a maintained copy of this repo.