update.sh 993 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. set -Eeuo pipefail
  3. image="${1:-hello-world}"
  4. echo hello-world "$image" | timeout 5s xargs -P2 -n1 docker pull &> /dev/null || exit 0
  5. exec > "$(dirname "$(readlink -f "$BASH_SOURCE")")/content.md"
  6. echo '# Example output'
  7. echo
  8. echo '```console'
  9. echo '$ docker run %%IMAGE%%'
  10. docker run --rm hello-world
  11. echo
  12. echo '$ docker images %%IMAGE%%'
  13. {
  14. id="$(docker image inspect --format '{{ .Id }}' "$image:latest" | sed -r 's/^sha256:([a-f0-9]{12})[a-f0-9]+$/\1/')"
  15. size="$(docker image inspect --format '{{ .VirtualSize }}' "$image:latest")"
  16. echo $'REPOSITORY\tTAG\tIMAGE ID\tSIZE'
  17. echo "$image"$'\tlatest\t'"$id"$'\t'"$size"
  18. } | column -t -s$'\t'
  19. echo '```'
  20. echo
  21. echo '%%LOGO%%'
  22. echo
  23. cat <<'EOF'
  24. # How is this image created?
  25. This image is a prime example of using the [`scratch`](https://hub.docker.com/_/scratch/) image effectively. See [`hello.c`](%%GITHUB-REPO%%/blob/master/hello.c) in %%GITHUB-REPO%% for the source code of the `hello` binary included in this image.
  26. EOF