You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

48 lines
2.5 KiB

  1. #!/usr/bin/env bash
  2. set -eu
  3. echo "post_checkout"
  4. source hooks/.config
  5. echo "Install qemu + binfmt support"
  6. echo "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯"
  7. # it's an Ubuntu VM and you can install stuff.
  8. apt-get update
  9. apt-get install -y curl qemu-user-static binfmt-support jq moreutils
  10. # Sadly docker itself uses Docker EE 17.06 on Dockerhub which does not support
  11. # manifests.
  12. echo "Install a fresh docker cli binary"
  13. echo "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯"
  14. curl https://download.docker.com/linux/static/stable/x86_64/docker-19.03.9.tgz | \
  15. tar xvz docker/docker
  16. echo "Build a usable config.json file"
  17. echo "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯"
  18. # Manifests are still experimental and enabled by a config file flag.
  19. # Interestingly, there is no config file and the credential parts to push
  20. # images is available in an environment variable. Let's create a config file to
  21. # combine the two things:
  22. #
  23. mkdir -p ~/.docker
  24. jq --null-input --argjson auths "$DOCKERCFG" '. + {auths: $auths}' | \
  25. jq --arg experimental enabled '. + {experimental: $experimental}' | \
  26. sponge ~/.docker/config.json
  27. echo "copy qemu binaries into docker build context"
  28. echo "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯"
  29. # The current setup copies the qemu binary into the image (see Dockerfile)
  30. # Pro:
  31. # - it's easy to run non-amd64 images on amd64 systems for debugging
  32. # Contra:
  33. # - it's dead weight in the "destination" architecture and consumes space
  34. # Alternative:
  35. # - use a multistage Dockerfile (no RUN in the last stage possible of course)
  36. # - wait for https://github.com/moby/moby/issues/14080
  37. #
  38. for arch in ${build_architectures[@]}; do
  39. cp /usr/bin/qemu-${docker_qemu_arch_map[${arch}]}-static qemu-${arch}-static
  40. done
  41. ls -la